Created
October 6, 2011 17:02
-
-
Save drguildo/1267961 to your computer and use it in GitHub Desktop.
Clojure tail call optimisation
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
(def rat | |
(fn x [a] | |
'(a) | |
(if (< a 10000) | |
(x (+ a 4))))) | |
(def mouse | |
(fn [a] | |
'(a) | |
(if (< a 10000) | |
(recur (+ a 4))))) | |
(print (with-out-str (time (rat 7)))) | |
(print (with-out-str (time (mouse 7)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment