Fun with lambda and map

ivo at nospamAmaze.nl ivo at nospamAmaze.nl
Mon Feb 4 11:38:07 EST 2002


Jason Orendorff <jason at jorendorff.com> wrote:
: Ivo wrote:
:> I implemented some of the pure (?) lambda calculus in python:
:> http://vanderwijk.info/lambda
:> Who needs '+' , 'if' and numbers? :)

: Wow.  It's extra cool that this should come up, because I just
: recently tore through the first chapter of SICP, and wrote this:

:   http://www.jorendorff.com/toys/truth.html

I extended the calculus a bit with mul (based on your sig :) and pred, 
hoping that I could fac in lambda, but I guess I've reached pythons lambda 
limits.

The statement:

fac = lambda q: if_then_else(is_zero(pred(q)))(n1)(mul(q, fac(pred(q))))

(check vanderwijk.info/lambda for the other definitions)

will recurse endlessly, because the else-part will always be evaluated
(but just not used as a result).

(why I do all this? Just pure academic interest - lambda calculus
used to fascinate me at the university)

	Ivo

-- 
Drs. I.R. van der Wijk                              -=-
Brouwersgracht 132                      Amaze Internet Services V.O.F.
1013 HA Amsterdam                                   -=-
Tel: +31-20-4688336                          Linux/Web/Zope/SQL
Fax: +31-20-4688337                           Network Solutions
Web:     http://www.amaze.nl/                    Consultancy
Email:   ivo at nospamAmaze.nl                         -=-




More information about the Python-list mailing list