import { evaluate } from './interpreter' import type { AST } from './ast' import type { Env } from './env' const ast: AST = { kind: 'binaryop', operator: '+', left: { kind: 'literal', value: { kind: 'int', value: 1 } }, right: { kind: 'binaryop', operator: '*', left: { kind: 'literal', value: { kind: 'int', value: 2 } }, right: { kind: 'literal', value: { kind: 'int', value: 3 } } } }; const env: Env = new Map(); const res = evaluate(ast, env); console.log(res); const ast2: AST = { kind: 'let', name: 'add', value: { kind: 'lambda', params: ['x', 'y'], body: { kind: 'binaryop', operator: '+', left: { kind: 'variable', name: 'x', }, right: { kind: 'variable', name: 'y', } } }, body: { kind: 'apply', func: { kind: 'variable', name: 'add' }, args: [ { kind: 'literal', value: { kind: 'int', value: 2 } }, { kind: 'literal', value: { kind: 'int', value: 3 } }, ] } }; const env2: Env = new Map(); const res2 = evaluate(ast2, env2); console.log(res2);