aboutsummaryrefslogtreecommitdiff
path: root/src/example/test1.lang
blob: 43f3111fab6561ccea21a4c5357c7968df4ba146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(* 5 6)

(def (repeat n val)
  (if (<=' n 0)
    (#Nil [])
    (#Cons [val (repeat (-' n 1) val)])))

(repeat 5 5)

(def (fold f init inputs)
  (case inputs
    (#Nil [])            init
    (#Cons [head tail]) (fold f (f init head) tail)))

(fold * 1 (repeat 5 5))