2024-05-10 23:11:34 +03:00
---
source: tests/golden_tests.rs
2024-05-15 01:25:46 +03:00
input_file: tests/golden_tests/parse_file/imp_program.bend
2024-05-10 23:11:34 +03:00
---
2024-05-15 21:23:26 +03:00
(Map/empty) = Map/Leaf
2024-05-15 16:42:16 +03:00
2024-05-15 21:23:26 +03:00
(Map/get) = λ%arg0 λ%arg1 use key = %arg1; use map = %arg0; match map = map { Map/Leaf: (*, map); Map/Node: switch _ = (== 0 key) { 0: switch _ = (% key 2) { 0: let (got, rest) = (Map/get map.left (/ key 2)); (got, (Map/Node map.value rest map.right)); _ _-1: let (got, rest) = (Map/get map.right (/ key 2)); (got, (Map/Node map.value map.left rest)); }; _ _-1: (map.value, map); }; }
2024-05-15 16:42:16 +03:00
2024-05-15 21:23:26 +03:00
(Map/set) = λ%arg0 λ%arg1 λ%arg2 use value = %arg2; use key = %arg1; use map = %arg0; match map = map { Map/Node: switch _ = (== 0 key) { 0: switch _ = (% key 2) { 0: (Map/Node map.value (Map/set map.left (/ key 2) value) map.right); _ _-1: (Map/Node map.value map.left (Map/set map.right (/ key 2) value)); }; _ _-1: (Map/Node value map.left map.right); }; Map/Leaf: switch _ = (== 0 key) { 0: switch _ = (% key 2) { 0: (Map/Node * (Map/set Map/Leaf (/ key 2) value) Map/Leaf); _ _-1: (Map/Node * Map/Leaf (Map/set Map/Leaf (/ key 2) value)); }; _ _-1: (Map/Node value Map/Leaf Map/Leaf); }; }
2024-05-15 16:42:16 +03:00
2024-05-14 23:22:16 +03:00
(symbols) = let x = (Map/set (Map/set Map/empty 49 5) 2 3); let x = (Map/set x 49 2); let x = (Map/set x 2 3); let (map/get%0, x) = (Map/get x 49); (+ map/get%0 8293490)
2024-05-10 23:11:34 +03:00
(mk_point) = (Point/Point 1 2)
2024-05-15 16:42:16 +03:00
(identity) = λ%arg0 use x = %arg0; x
2024-05-10 23:11:34 +03:00
2024-05-15 16:42:16 +03:00
(inc) = λ%arg0 use n = %arg0; let n = (+ n 1); n
2024-05-10 23:11:34 +03:00
2024-05-21 23:06:51 +03:00
(inc_list) = λ%arg0 use list = %arg0; fold %iter = list { List/Nil: List/Nil; List/Cons: let x = %iter.head; (List/Cons (+ x 1) %iter.tail); }
2024-05-10 23:11:34 +03:00
(lam) = λx λy x
2024-05-15 16:42:16 +03:00
(do_match) = λ%arg0 use b = %arg0; match b = b { Bool/True: 1; Bool/False: 0; }
2024-05-10 23:11:34 +03:00
(true) = Bool/True
2024-05-15 16:42:16 +03:00
(fib) = λ%arg0 use n = %arg0; switch %pred = (< n 2) { 0: (+ (fib (- n 1)) (fib (- n 2))); _ %pred-1: n; }
2024-05-10 23:11:34 +03:00
2024-05-15 16:42:16 +03:00
(swt) = λ%arg0 use n = %arg0; switch n = n { 0: 42; _ n-1: 1; }
2024-05-10 23:11:34 +03:00
2024-05-17 19:08:51 +03:00
(fld) = λ%arg0 use list = %arg0; fold list = list { List/Cons: 1; List/Nil: 2; }
2024-05-10 23:11:34 +03:00
2024-05-17 19:08:51 +03:00
(bnd) = bend x = 0, { when (< x 10): (List/Cons x (fork (+ x 1))); else: List/Nil }
2024-05-13 18:23:20 +03:00
2024-05-15 15:33:16 +03:00
(era) = let * = (+ 2 3); let the_expr_killer = *; (the_expr_killer 9)
2024-05-19 18:06:52 +03:00
(sup) = let x = {(List/Cons 1 (List/Cons 2 List/Nil)) (List/Cons 3 (List/Cons 4 (List/Cons 5 (List/Cons 6 List/Nil))))}; x
2024-05-28 22:49:00 +03:00
(main) = with IO { ask x = IO.read; x }
2024-05-14 15:33:16 +03:00
2024-05-27 21:09:23 +03:00
(List/Nil) = λ%x (%x List/Nil/tag)
2024-05-17 19:08:51 +03:00
2024-05-27 21:09:23 +03:00
(List/Cons) = λhead λtail λ%x (%x List/Cons/tag head tail)
2024-05-17 19:08:51 +03:00
2024-05-27 21:09:23 +03:00
(Map/Node) = λvalue λleft λright λ%x (%x Map/Node/tag value left right)
2024-05-14 15:33:16 +03:00
2024-05-27 21:09:23 +03:00
(Map/Leaf) = λ%x (%x Map/Leaf/tag)
2024-05-14 15:33:16 +03:00
2024-05-27 21:09:23 +03:00
(Point/Point) = λx λy λ%x (%x Point/Point/tag x y)
2024-05-14 15:33:16 +03:00
2024-05-27 21:09:23 +03:00
(Bool/True) = λ%x (%x Bool/True/tag)
2024-05-14 15:33:16 +03:00
2024-05-27 21:09:23 +03:00
(Bool/False) = λ%x (%x Bool/False/tag)
(List/Nil/tag) = 0
(List/Cons/tag) = 1
(Map/Node/tag) = 0
(Map/Leaf/tag) = 1
(Point/Point/tag) = 0
(Bool/True/tag) = 0
(Bool/False/tag) = 1