RSS Amplifier

kilotau.com on kilotau.com - reading, thinking, and learning · Jul 2, 2012

Y Combinator in Clojure

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

( defn Y [r]
 (( fn [f] ( f f))
 ( fn [f]
 ( r ( fn [x] (( f f) x))))))
 There’s few things as iconic as the Y-Combinator in functional programming. 
 The Y combinator can be thought of as a higher-order function that takes a function (which represents some sort of recursive logic) and returns its fixed point. This fixed point is the recursive function you want to call…

(defn Y [r]
  ((fn [f] (f f))
   (fn [f]
     (r (fn [x] ((f f) x))))))

There’s few things as iconic as the Y-Combinator in functional programming.

The Y combinator can be thought of as a higher-order function that takes a function (which represents some sort of recursive logic) and returns its fixed point. This fixed point is the recursive function you want to call repeatedly.

What’s a fixed point?

Read on /posts/2012-07-02-y-combinator-in-clojure/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.