A critic of Guido's blog on Python's lambda
Frank Buss
fb at frank-buss.de
Sun May 7 15:22:33 EDT 2006
Alex Martelli wrote:
> Sorry, but I just don't see what lambda is buying you here. Taking just
> one simple example from the first page you quote, you have:
>
> (defun blank ()
> "a blank picture"
> (lambda (a b c)
> (declare (ignore a b c))
> '()))
You are right, for this example it is not useful. But I assume you need
something like lambda for closures, e.g. from the page
http://www.frank-buss.de/lisp/texture.html :
(defun black-white (&key function limit)
(lambda (x y)
(if (> (funcall function x y) limit)
1.0
0.0)))
This function returns a new function, which is parametrized with the
supplied arguments and can be used later as building blocks for other
functions and itself wraps input functions. I don't know Python good
enough, maybe closures are possible with locale named function definitions,
too.
--
Frank Buss, fb at frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
More information about the Python-list
mailing list