Last active
August 29, 2015 14:15
-
-
Save LispyAriaro/6708133a00eab98fa0c5 to your computer and use it in GitHub Desktop.
Reversing a list without using the reverse function
This file contains 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
;;;puttin letfn to work | |
;;;reverse without the 'reverse' function | |
(fn[lst] | |
(letfn [(my-fun [lst so-far] | |
(if (empty? lst) | |
so-far | |
(recur (butlast lst) | |
(conj so-far (last lst)))))] | |
(println (my-fun lst [])))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment