[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lambda calculus and it relation to LISP
From: |
David Kastrup |
Subject: |
Re: Lambda calculus and it relation to LISP |
Date: |
07 Oct 2002 11:34:22 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
see@sig.below (Barb Knox) writes:
> In article <9e8ebeb2.0210062058.5c7ab267@posting.google.com>,
> gnuist007@hotmail.com (gnuist) wrote:
> [snip]
>
> > In the same way I ask for GRADED examples of use of lambda. I am sure many
> > of you can just cut and paste from your collection. Examples to illustrate
> > recursion, etc. And how will you do recursion without/with "LABEL"?
>
> Lambda calculus does not have Lisp's LABEL/LABELS or DEFUN/DE. Recursion
> is done via the "Y combinator", which is a very interesting
> self-referential hack (in the good sense).
>
> For example, here is a recursive factorial function in lambda calculus in
> Lispish syntax (assuming apprioriate definitions for 'if', '<', '*', '-',
> and '1'). It takes one argument (which gets bound to 'n') and returns its
> factorial.
>
> ((lambda (f) ((lambda (Y) (f (Y Y))) (lambda (Y) (f (Y Y)))))
> (lambda (ff n) (if (< n 1) 1 (* n (ff (- n 1))))) )
>
> Intense, eh?
Also wrong. This is "Lispish Syntax", actually Scheme. So we can
check it out:
guile> ((lambda (f) ((lambda (Y) (f (Y Y))) (lambda (Y) (f (Y Y)))))(lambda (ff
n) (if (< n 1) 1 (* n (ff (- n 1))))) )
standard input:1:27: In expression (f (Y Y)):
standard input:1:27: Wrong number of arguments to #<procedure (ff n)>
ABORT: (wrong-number-of-args)
Type "(backtrace)" to get more information.
guile> (backtrace)
Backtrace:
0* [#<procedure (f)> #<procedure (ff n)>]
1 [#<procedure (Y)> #<procedure (Y)>]
2 (f (Y Y))
Type "(debug-enable 'backtrace)" if you would like a backtrace
automatically if an error occurs in the future.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de
- Re: Lambda calculus and it relation to LISP, (continued)
- Re: Lambda calculus and it relation to LISP, Charles Matthews, 2002/10/05
- Re: Lambda calculus and it relation to LISP, Gareth McCaughan, 2002/10/05
- Re: Lambda calculus and it relation to LISP, William Elliot, 2002/10/06
- Re: Lambda calculus and it relation to LISP, Gareth McCaughan, 2002/10/06
- Re: Lambda calculus and it relation to LISP, gnuist, 2002/10/07
- Re: Lambda calculus and it relation to LISP, William Elliot, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Barb Knox, 2002/10/07
- Re: Lambda calculus and it relation to LISP,
David Kastrup <=
- Re: Lambda calculus and it relation to LISP, William Elliot, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Barb Knox, 2002/10/07
- Re: Lambda calculus and it relation to LISP, William Elliot, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Christian Lemburg, 2002/10/07
- Re: Lambda calculus and it relation to LISP, ozan s yigit, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Barb Knox, 2002/10/07
- Re: Lambda calculus and it relation to LISP, David Kastrup, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Gareth McCaughan, 2002/10/07
- Re: Lambda calculus and it relation to LISP, William Elliot, 2002/10/07
- Re: Lambda calculus and it relation to LISP, Gareth McCaughan, 2002/10/07