Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Y Combinator in Scheme using Define

In order to learn what a fixed-point combinator is and is used for, I wrote my own. But instead of writing it with strictly anonymous functions, like Wikipedia's example, I just used define:

(define combine (lambda (functional)
                  (functional (lambda args (apply (combine functional) args))))

I've tested this with functionals for factorial and fibonacci, and it seems to work. Does this meet the formal definition of a fixed-point combinator?

like image 925
AlcubierreDrive Avatar asked Jan 14 '11 01:01

AlcubierreDrive


People also ask

What is Y Combinator in programming?

The Y combinator is a formula which lets you implement recursion in a situation where functions can't have names but can be passed around as arguments, used as return values, and defined within other functions. It works by passing the function to itself as an argument, so it can call itself.

Which programming construct is made possible by the Y Combinator?

Basically, it's this: The Y combinator allows us to define recursive functions in computer languages that do not have built-in support for recursive functions, but that do support first-class functions. That's it.

What is important about the lambda calculus expression called Y Combinator '?

The Y combinator is a central concept in lambda calculus, which is the formal foundation of functional languages. Y allows one to define recursive functions without using self-referential definitions.


1 Answers

EDIT: While chessweb or anyone else corroborates his answer, temporarily consider his answer correct and this one wrong.


It seems the answer is yes. Apparently the exact same combinator appears here, midway down the page:

(define Y
    (lambda (f)
      (f (lambda (x) ((Y f) x)))))
like image 52
AlcubierreDrive Avatar answered Sep 27 '22 20:09

AlcubierreDrive