Skip to content

Instantly share code, notes, and snippets.

@drguildo
Created October 6, 2011 17:02
Show Gist options
  • Save drguildo/1267961 to your computer and use it in GitHub Desktop.
Save drguildo/1267961 to your computer and use it in GitHub Desktop.
Clojure tail call optimisation
(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