Re: Whoa! Do Python and Lisp really have LAMBDA ?
From: Karl A. Krueger (kkrueger_at_example.edu)
Date: 10/27/03
- Next message: Pascal Costanza: "Re: Python from Wise Guy's Viewpoint"
- Previous message: Joshua Eckroth: "Re: Pure LISP implementation"
- In reply to: Marco Antoniotti: "Re: Whoa! Do Python and Lisp really have LAMBDA ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 27 Oct 2003 16:02:20 +0000 (UTC)
In comp.lang.lisp Marco Antoniotti <marcoxa@cs.nyu.edu> wrote:
> Common Lisp does it right.
>
> (mapcar (lambda (f) (funcall f 1))
> (mapcar (lambda (i)
> (lambda (x) (+ x i)))
> (list 1 2 3)))
>
> ... This is what the Haskell code eventually boild down to.
>
> It is Python that apparently cannot do this. But, in all fairness,
> nowhere in Python there is a claim that lambda expressions are full fledged.
Python lambda isn't *that* limited. It's just that the equivalent is
rather ugly by Python standards:
[f(1) for f in
[(lambda i: lambda x: x + i)(y)
for y in [1, 2, 3]]]
This also works, but isn't any prettier:
map(lambda f: apply(f, (1,)),
map(lambda i:
lambda x: (x + i),
[1, 2, 3]))
(Bleah. All those colons and commas are giving me MPI flashbacks.)
-- Karl A. Krueger <kkrueger@example.edu> Woods Hole Oceanographic Institution Email address is spamtrapped. s/example/whoi/ "Outlook not so good." -- Magic 8-Ball Software Reviews
- Next message: Pascal Costanza: "Re: Python from Wise Guy's Viewpoint"
- Previous message: Joshua Eckroth: "Re: Pure LISP implementation"
- In reply to: Marco Antoniotti: "Re: Whoa! Do Python and Lisp really have LAMBDA ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|