diff --git a/tapl/tests/mlish/sweet-map.rkt b/tapl/tests/mlish/sweet-map.rkt new file mode 100644 index 0000000..7d6321d --- /dev/null +++ b/tapl/tests/mlish/sweet-map.rkt @@ -0,0 +1,20 @@ +#lang sweet-exp "../../mlish.rkt" + +define + sum [lst : (List Int)] → Int + match lst with + [] -> 0 + x :: xs -> + {x + sum(xs)} + +define + map [f : (→ X Y)] [lst : (List X)] → (List Y) + match lst with + [] -> nil + x :: xs -> + cons + f x + map f xs + +sum + map string->number (list "1" "2" "3")