18 lines
360 B
Plaintext
18 lines
360 B
Plaintext
;; 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
|
|
(assert-eq? 7 ( (-> (x y) (+ x y 1)) 2 4 ))
|
|
|
|
;; syntaxic sugar for function declaration
|
|
($ (c n) (* 2 n))
|
|
(assert-eq? 18 (c 9))
|
|
|
|
;; inner variable
|
|
($ (d x) ($ y 3) (+ x y))
|
|
(assert-eq? 7 (d 4)) |