grino/examples/fun.gri

14 lines
294 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))