Skip to content

Instantly share code, notes, and snippets.

@jasonjckn
Created June 5, 2011 01:15
Show Gist options
  • Save jasonjckn/1008549 to your computer and use it in GitHub Desktop.
Save jasonjckn/1008549 to your computer and use it in GitHub Desktop.
(defn Y [f]
(f f))
((Y (fn [coll]
(if-let [[a0 & as] (seq coll)]
(+ a0 ((h h) as))
0)))
[1 2 3 4 5])
@jasonjckn
Copy link
Author

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)

@amalloy
Copy link

amalloy commented Jun 5, 2011

(fn [coll]
  (if-let [[a & as] (seq coll)]
    ...))

@jasonjckn
Copy link
Author

Perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment