y-combinator

Good explanation of "Combinators" (For non mathematicians)

Anyone got a good explanation of "combinators" (Y-combinators etc. and NOT the company) I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background. (Note that I'm talking about these things : http://en.wikipedia.org/wiki/Y_combinator ) ...

Fixed point combinators in C++

I'm interested in actual examples of using fixed point combinators (such as the y-combinator in C++. Have you ever used a fixed point combinator with egg or bind in real live code? I found this example in egg a little dense: void egg_example() { using bll::_1; using bll::_2; int r = fix2( bll::ret<int>(...

Can a lambda function call itself recursively in Python?

A regular function can contain a call to itself in its definition, no problem. I can't figure out how to do it with a lambda function though for the simple reason that the lambda function has no name to refer back to. Is there a way to do it? How? ...

Y-Combinator Practical Example

I've been reading a bit lately about functional programming and I am trying to grok the Y-Combinator. I understand that you can use the Y-Combinator to effectively implement recursion in a language that doesn't support recursion directly. However, every language that I'm likely to use already supports recursion so I'm not sure how usef...

Recursive lambdas in F#

Take this example code (ignore it being horribly inefficient for the moment) let listToString (lst:list<'a>) = ;;' prettify fix let rec inner (lst:list<'a>) buffer = ;;' prettify fix match List.length lst with | 0 -> buffer | _ -> inner (List.tl lst) (buffer + ((List.hd lst).ToString())) inner lst "" ...

How do I define y-combinator without "let rec"?

In almost all examples, a y-combinator in ML-type languages is written like this: let rec y f x = f (y f) x let factorial = y (fun f -> function 0 -> 1 | n -> n * f(n - 1)) This works as expected, but it feels like cheating to define the y-combinator using let rec .... I want to define this combinator without using recursion, using t...

Rosetta Stone: Y-combinator

The Y-combinator is defined as: Y = λf. (λx. f (x x)) (λx. f (x x)) Using this combinator, you can write recursive lambda functions or intercept recursive methods with custom code. How is the Y-combinator written in various languages? I'd be interested in seeing the Y-combinator defined and used to implement a recursive factorial fu...

Fixed point combinator usage? Why a stack overflow here?

I am confused about something. I wanted to generate an example (in Clojure) demonstrating how a fixed point combinator could be used to evaluate the fixed point of a sequence that mathematically converges after an infinite number of applications but would, in fact, converge after a finite number of steps due to finite precision of floati...

Applying the Y-Combinator to a recursive function with two arguments in Clojure?

Doing the Y-Combinator for a single argument function such as factorial or fibonacci in Clojure is well documented: http://rosettacode.org/wiki/Y_combinator#Clojure My question is - how do you do it for a two argument function such as this getter for example? (Assumption here is that I want to solve this problem recursively and this n...

Y Combinator's most successful investment?

Curios to know, which of Y Combinators investments has financially been the most successful. Seems like everyone points our Reddit.com, but from what I gathered - the site wasn't really sold for all that much money. ...