Skip to content

Instantly share code, notes, and snippets.

@kencoba
Created March 9, 2011 05:02
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 kencoba/861720 to your computer and use it in GitHub Desktop.
Save kencoba/861720 to your computer and use it in GitHub Desktop.
y-combinator
(use 'clojure.contrib.trace)
(defn fact-gen [fact-in]
(fn [n]
(if (= n 0)
1
(* n (fact-in (- n 1))))))
(defn Y [r]
((fn [f] (f f))
(fn [f] (r (fn [x] ((f f) x))))))
(dotrace [fact-gen] ((Y fact-gen) 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment