Improve recursive-reverse
This commit is contained in:
parent
cdd46053a9
commit
4bd3bc9a72
1 changed files with 4 additions and 4 deletions
|
|
@ -14,10 +14,10 @@
|
|||
(recur (dec n) (not acc)))))
|
||||
|
||||
(defn recursive-reverse [coll]
|
||||
(loop [coll coll acc '()]
|
||||
(if (= coll [])
|
||||
acc
|
||||
(recur (rest coll) (conj acc (first 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 n]
|
||||
|
|
|
|||
Loading…
Reference in a new issue