Belgi
Belgi

Reputation: 15062

Recursion in LISP without using labels

I started learning LISP and I heard that there is some kind of a trick to do recursion without using lables (only using : quote,atom,eq,car,cdr,cons,cond).

I gave it some thought but I can't think of a way doing this since the function I defined has no name.

I'm guessing its done using cond by I don't really see how...

[the question is how to implement recursion with the limitations as stated above]

Upvotes: 1

Views: 367

Answers (1)

Derrick Turk
Derrick Turk

Reputation: 4336

For anonymous recursion, you're going to need a fixed-point combinator, the most famous of which is known as the Y combinator. Richard Gabriel's "Why of Y" is a good article which derives and justifies Y in Scheme.

Upvotes: 5

Related Questions