Re: Whoa! Do Python and Lisp really have LAMBDA ?
From: Karl A. Krueger (kkrueger_at_example.edu)
Date: Mon, 27 Oct 2003 16:02:20 +0000 (UTC)
In comp.lang.lisp Marco Antoniotti <email@example.com> 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,)),
lambda x: (x + i),
[1, 2, 3]))
(Bleah. All those colons and commas are giving me MPI flashbacks.)
-- Karl A. Krueger <firstname.lastname@example.org> Woods Hole Oceanographic Institution Email address is spamtrapped. s/example/whoi/ "Outlook not so good." -- Magic 8-Ball Software Reviews