specialForms = ({
'let': (e, scope, variable, value, expression) => {
const lexicalScope = { ...scope };
lexicalScope[variable] = value;
return e(expression, lexicalScope);
},
fn: (e, scope, functionName, argNames, body) => {
scope[functionName] = (fnScope, ...args) => {
const argNameValuePairs = argNames.map((arg, index) => [
arg,
args[index],
]);
console.log(argNameValuePairs);
console.log(
argNameValuePairs
);
const fnLocalScope = {
...fnScope,
...argNames
.map((arg, index) => [arg, args[index]])
.reduce((acc, [arg, val]) => ({ ...acc, [arg]: val }), {})
};
return e(body, fnLocalScope);
};
},
})