"use strict";
var expect = require('expect.js');
var fs = require('fs');
var List = require('./list.js');
var Pair = require('../lib/pair.js');
var String = require('../lib/string.js');
var PP = require('../lib/pprinter.js');
var Env = require('../lib/env.js');
var IO = require('../lib/monad.js').IO;
var ID = require('../lib/monad.js').ID;
var Cont = require('../lib/monad.js').Cont;
const Evaluator = {
ID: {
Exp: {
match : (data, pattern) => {
return data(pattern);
},
num: (value) => {
return (pattern) => {
return pattern.num(value);
};
},
variable : (name) => {
return (pattern) => {
return pattern.variable(name);
};
},
lambda: (variable, body) => {
return (pattern) => {
return pattern.lambda(variable, body);
};
},
app: (lambda, arg) => {
return (pattern) => {
return pattern.app(lambda, arg);
};
},
add : (expL,expR) => {
return (pattern) => {
return pattern.add(expL, expR);
};
},
subtract : (expL,expR) => {
return (pattern) => {
return pattern.subtract(expL, expR);
};
},
divide : (expL,expR) => {
return (pattern) => {
return pattern.divide(expL, expR);
};
},
multiply : (expL,expR) => {
return (pattern) => {
return pattern.multiply(expL, expR);
};
}
},
evaluate: (anExp, environment) => {
return Evaluator.ID.Exp.match(anExp,{