evaluating pattern matching

This commit is contained in:
Dustin Swan 2026-02-01 19:22:50 -07:00
parent 7f94cfe8cd
commit a85203bc94
No known key found for this signature in database
GPG key ID: 30D46587E2100467
4 changed files with 102 additions and 9 deletions

View file

@ -13,7 +13,7 @@ function e(str: string) {
console.log(ast);
console.log(prettyPrint(ast));
const env: Env = new Map();
// console.log(evaluate(ast, env));
console.log(evaluate(ast, env));
}
e('add1 = (x \\ x + 1); add1 3');
@ -26,5 +26,8 @@ e('add1 = (x \\ x + 1); 3 > add1');
e('[1, 2] & [3, 4]');
e('"abc" & "def"');
// e('n | 0 \\ 1 | _ \\ 99');
e('m | Some x \\ 1 | None \\ 0');
e('head = list \\ list | [x, _] \\ Some x | [] \\ None; head');
// e('m | Some x \\ 1 | None \\ 0');
// e('head = list \\ list | [x, _] \\ Some x | [] \\ None; head');
e('n = 5; n | 5 \\ "five" | _ \\ "other"');
e('list = [1, 2, 3]; list | [x, y, z] \\ x + y + z');
e('point = {x = 5, y = 10}; point | {x = px, y = py} \\ px + py');