Created
December 4, 2011 00:58
-
-
Save noahlz/1428694 to your computer and use it in GitHub Desktop.
Recursive version of clojure reverse function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn reverse-recursively [coll] | |
| (loop [r (rest coll) | |
| acc (conj () (first coll))] | |
| (if (= (count r) 0) | |
| acc | |
| (recur (rest r) (conj acc (first r)))))) |
Author
Author
user> (reverse-recursively [])
(nil)
D'oh...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feedback from StackOverflow
http://stackoverflow.com/questions/8395064/recursively-reverse-a-sequence-in-clojure