Permalink
Browse files

adding "lambda" definition

  • Loading branch information...
1 parent 0ab1bde commit 951a3e9ce9d7df49fef515fb98988ebbc4840b22 @ajb committed May 7, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 Homework5/scheem.js
View
@@ -116,6 +116,18 @@ var evalScheem = function (expr, env) {
var newEnv = {bindings: binding, outer: env};
return evalScheem(expr[2], newEnv);
};
+ case 'lambda':
+ return function(){ // use arguments object
+ var exprs = expr[1];
+ var binding = {};
+ for(var i = 0; i < arguments.length; ++i){
+ binding[exprs[i]] = arguments[i];
+ }
+
+ var newEnv = {bindings: binding, outer: env};
+ return evalScheem(expr[2], newEnv);
+ }
+
default:
var func = evalScheem(expr[0], env);
var args = expr;

0 comments on commit 951a3e9

Please sign in to comment.