5

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?

1
  • Exercise 2: Y combinator without using define or letrec :) Commented Jan 14, 2011 at 6:13

2 Answers 2

5

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)))))
Sign up to request clarification or add additional context in comments.

2 Comments

You shouldn't. You're encouraged to answer you own questions. IIRC you can accept your own answer in 2 days after you gave it.
The main point of teaching the Y combinator is to see how you can implement recursion with just functions. By writing a recursive definition, you fail to do that -- so you end up with something that works, but it's only useful in understanding what Y is supposed to do. Mike's text would be a good place to read about it in depth and see how the define-less version is derived.
3

The answer is no, because according to the blog referred to in the previous answer, it doesn't even meet the definition of combinator, since 'combine' is a free variable.

1 Comment

Thanks for pointing that out. Just to be sure that the blog's definition is correct, do you consider it equivalent to Wikipedia's definition: "A combinator is a higher-order function that uses only function application and earlier defined combinators to define a result from its arguments."? See en.wikipedia.org/wiki/Combinatory_logic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.