commit
fac0657300
1 changed files with 11 additions and 5 deletions
|
|
@ -3,21 +3,27 @@
|
|||
|
||||
(defn is-even? [n]
|
||||
(if (= n 0)
|
||||
__
|
||||
(___ (is-even? (dec n)))))
|
||||
true
|
||||
(not (is-even? (dec n)))))
|
||||
|
||||
(defn is-even-bigint? [n]
|
||||
(loop [n n
|
||||
acc true]
|
||||
(if (= n 0)
|
||||
__
|
||||
acc
|
||||
(recur (dec n) (not acc)))))
|
||||
|
||||
(defn recursive-reverse [coll]
|
||||
__)
|
||||
(loop [[head & tail] coll new-coll '()]
|
||||
(if-not head
|
||||
new-coll
|
||||
(recur tail (conj new-coll head)))))
|
||||
|
||||
(defn factorial [n]
|
||||
__)
|
||||
(loop [n n acc 1]
|
||||
(if (= n 1)
|
||||
acc
|
||||
(recur (dec n) (* acc n)))))
|
||||
|
||||
(meditations
|
||||
"Recursion ends with a base case"
|
||||
|
|
|
|||
Loading…
Reference in a new issue