-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.h
57 lines (47 loc) · 1.44 KB
/
lambda.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* File: lambda.h
* --------------
* Helps us model and evaluate lambda expressions, which are
* Scheme's way of expressing functions.
*/
#ifndef __scheme_lambda__
#define __scheme_lambda__
#include "genlib.h"
#include "expression.h"
#include "callable.h"
#include "symbol.h"
#include "vector.h"
/**
* Helps us model and evaluate lambda expressions, which are
* Scheme's way of expressing functions. For example:
*
* (lambda (x y) (+ x y))
*
* is the function that presumably returns the sum of whatever
* two numbers are supplied as parameters.
*
* (lambda () "hello, world!")
*
* is the zero-argument function that always evaluates to the
* "hello, world!" string. And:
*
* (lambda (x y) (lambda (z) (+ x y z)))
*
* is a two-argument function that evaluates to a one-argument function
* whose implementation involves whatever the x and y evaluated to. Deep.
*/
class LambdaExpression : public Callable {
public:
string toString() { return "<lambda>"; }
Expression *call(Vector<Expression *>& arguments,
EvalState& state);
LambdaExpression(Expression *parameterList,
Expression *parameterizedExpression);
protected:
// Expression * create(Vector<Expression *> & arguments, EvalState& state);
// Expression * calculate(Vector<Expression *> & arguments, EvalState& localstate);
Vector<SymbolExpression *> locals;
Expression * exp;
// bool defined = false;
};
#endif