Q about tail recursion

Jon K Hellan hellan at acm.org
Sun Feb 27 21:43:24 CET 2000

Felix Thibault <felixt at dicksonstreet.com> writes:
> Well, then here's the real question on my mind that I've been too 
> embarassed to ask till now:
> Is there a Python version of this scheme function that has informative
> variable names so I can figure out what it does ?
> Or just - what does this do:
> (define Y
> 	(lambda (le)
> 		((lambda (f) (f f))
> 		 (lambda (f)
> 		   (le (lambda (x) ((f f) x))))))) ?
> y'rs ly-unpythonic
> Felix-

It's the Y combinator in lambda calculus. You can read about it in
e.g. "The Seasoned Schemer" by Daniel P. Friedman and Matthias
Felleisen. The function you quoute may well be from that book. At
hand-waving level, it's a device to turn a function into a recursive
function. Don't ask me to reveal my level of ignorance by trying to
explain further!

Jon Kåre

More information about the Python-list mailing list