add mlish/sweet-map.rkt test
This commit is contained in:
parent
94ae1ebabe
commit
c45e967896
20
tapl/tests/mlish/sweet-map.rkt
Normal file
20
tapl/tests/mlish/sweet-map.rkt
Normal file
|
@ -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")
|
Loading…
Reference in New Issue
Block a user