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_map.bend
2024-05-10 23:11:34 +03:00
---
2024-05-15 21:23:26 +03:00
(Map/empty) = Map/Leaf
2024-05-10 23:11:34 +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-10 23:11:34 +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-10 23:11:34 +03:00
2024-05-14 15:33:16 +03:00
(main) = let x = (Map/set (Map/set Map/empty 2 1) 3 2); let (map/get%1, x) = (Map/get x 2); let y = (id map/get%1); let z = 4; let x = (Map/set x z 4); let (map/get%0, x) = (Map/get x z); (+ y map/get%0)
2024-05-14 15:00:56 +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:00:56 +03:00
2024-05-27 21:09:23 +03:00
(Map/Leaf) = λ%x (%x Map/Leaf/tag)
(Map/Node/tag) = 0
(Map/Leaf/tag) = 1