2023-09-11 18:59:54 +00:00
|
|
|
;; declare lambda
|
|
|
|
($ a (-> (x) (* x 2)))
|
|
|
|
(assert-eq? 14 (a 7))
|
|
|
|
|
|
|
|
;; high order function
|
|
|
|
($ b (-> (x y) (x (x y))))
|
|
|
|
(assert-eq? 12 (b a 3))
|
|
|
|
|
|
|
|
;; calling function literal
|
2023-09-11 20:18:11 +00:00
|
|
|
(assert-eq? 7 ( (-> (x y) (+ x y 1)) 2 4 ))
|
|
|
|
|
|
|
|
;; syntaxic sugar for function declaration
|
|
|
|
($ (c n) (* 2 n))
|
|
|
|
(assert-eq? 18 (c 9))
|