Skip to content

Commit 3dc2890

Browse files
committed
Make lambda definition just a JS fn.
* Compatible with new regime where invocation code just checks to see if first element of list is a JS function.
1 parent 801f5d9 commit 3dc2890

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

tinylisp.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@
3434
},
3535

3636
lambda: function(input, context) {
37-
return {
38-
type: "invocation",
39-
value: function(args) {
40-
var lambdaScope = input[1].reduce(function(acc, x, i) {
41-
acc[x.value] = args[i];
42-
return acc;
43-
}, {});
44-
return interpret(input[2], new Context(lambdaScope, context));
45-
}
37+
return function() {
38+
var lambdaArguments = arguments;
39+
var lambdaScope = input[1].reduce(function(acc, x, i) {
40+
acc[x.value] = lambdaArguments[i];
41+
return acc;
42+
}, {});
43+
return interpret(input[2], new Context(lambdaScope, context));
4644
};
4745
},
4846

@@ -96,6 +94,7 @@
9694
}
9795
};
9896

97+
// do this without depth
9998
var parenthesize = function(input) {
10099
var output = [];
101100
var depth = 0;

0 commit comments

Comments
 (0)