parent
ea5991732c
commit
29fded5cb9
|
@ -29,3 +29,24 @@
|
||||||
(if (eq? x 0)
|
(if (eq? x 0)
|
||||||
1
|
1
|
||||||
(* x (self (- x 1))))) 6))
|
(* x (self (- x 1))))) 6))
|
||||||
|
|
||||||
|
;; inner functions
|
||||||
|
($ (f n)
|
||||||
|
($ (inner n) (+ n 1))
|
||||||
|
(inner (inner n)))
|
||||||
|
|
||||||
|
(assert-eq? 3 (f 1))
|
||||||
|
|
||||||
|
;; return function
|
||||||
|
($ (g)
|
||||||
|
($ (inner n) (* 7 n))
|
||||||
|
inner)
|
||||||
|
|
||||||
|
(assert-eq? 42 ( (g) 6 ))
|
||||||
|
|
||||||
|
;; return lambda
|
||||||
|
($ (h)
|
||||||
|
(-> (n)
|
||||||
|
(* 3 (- n 2))))
|
||||||
|
|
||||||
|
(assert-eq? 15 ( (h) 7 ))
|
Loading…
Reference in New Issue