Initial commit
This commit is contained in:
parent
8a5603e637
commit
4e3a048296
12
SICP/exercise_1_43.janet
Normal file
12
SICP/exercise_1_43.janet
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
(defn compose [f g]
|
||||||
|
(fn [x] (f (g x))))
|
||||||
|
(defn repeated [f n]
|
||||||
|
(defn iter [inner_f k]
|
||||||
|
(cond
|
||||||
|
(= k 1) inner_f
|
||||||
|
(iter (compose f inner_f) (- k 1))))
|
||||||
|
(iter f n))
|
||||||
|
|
||||||
|
(defn square [x] (* x x))
|
||||||
|
|
||||||
|
(print ((repeated square 2) 5))
|
||||||
Loading…
Reference in New Issue
Block a user