www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

sweet-map.rkt (330B)


      1 #lang sweet-exp "../../mlish.rkt"
      2 
      3 define
      4   sum [lst : (List Int)] → Int
      5   match lst with
      6     [] -> 0
      7     x :: xs ->
      8       {x + sum(xs)}
      9 
     10 define
     11   map [f : (→ X Y)] [lst : (List X)] → (List Y)
     12   match lst with
     13     [] -> nil
     14     x :: xs ->
     15       cons
     16         f x
     17         map f xs
     18 
     19 sum
     20   map string->number (list "1" "2" "3")