Skip to content

Instantly share code, notes, and snippets.

@joehakimrahme
Created June 28, 2013 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joehakimrahme/5885156 to your computer and use it in GitHub Desktop.
Save joehakimrahme/5885156 to your computer and use it in GitHub Desktop.
(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