Created
June 28, 2013 14:36
-
-
Save joehakimrahme/5885156 to your computer and use it in GitHub Desktop.
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
(defn trampoline [func] | |
(defn trampolined-func [*args] | |
(setv f (func *args)) | |
(while (callable f) | |
(setv f (f))) | |
f) | |
trampolined-func) | |
(with-decorator trampoline | |
(defn fibo [n] | |
(if (<= n 1) | |
n | |
(lambda [] (+ (fibo (- n 1)) (fibo (- n 2))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment