Skip to content

Instantly share code, notes, and snippets.

@noahlz
Created December 4, 2011 00:58
Show Gist options
  • Select an option

  • Save noahlz/1428694 to your computer and use it in GitHub Desktop.

Select an option

Save noahlz/1428694 to your computer and use it in GitHub Desktop.
Recursive version of clojure reverse function
(defn reverse-recursively [coll]
(loop [r (rest coll)
acc (conj () (first coll))]
(if (= (count r) 0)
acc
(recur (rest r) (conj acc (first r))))))
@noahlz
Copy link
Author

noahlz commented Dec 6, 2011

@noahlz
Copy link
Author

noahlz commented Dec 6, 2011

user> (reverse-recursively [])
(nil)

D'oh...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment