Created
June 5, 2011 01:15
-
-
Save jasonjckn/1008549 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 Y [f] | |
(f f)) | |
((Y (fn [coll] | |
(if-let [[a0 & as] (seq coll)] | |
(+ a0 ((h h) as)) | |
0))) | |
[1 2 3 4 5]) |
try to paste this code again:
(defn sum-gen [h] (fn [[a0 & as :as a]] (if (seq a) (+ a0 ((h h) as)) 0)))
Anyways, now the ycombinator is laughably simple.
The more complex version is just to get prettier anonymous function declarations, such as:
(defn sum-gen [h] (fn [[a0 & as :as a]] (if (seq a) (+ a0 (h as)) 0)))
instead of (h h)
(fn [coll]
(if-let [[a & as] (seq coll)]
...))
Perfect!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, you're right about as. Silly me.