Of what use is 'lambda'???

Grant Edwards ge at nowhere.none
Tue Sep 19 16:43:01 CEST 2000

In article <8q6i9q$7m5$1 at panix6.panix.com>, Aahz Maruch wrote:

>>The lambda definition is limited to only one expression, and everything
>>you do with lambda, can also be done with plain functions.
>Yup.  Lambda is worthless.  Don't use it.
>(I'm half-joking, but only half-joking.  Try learning Lisp or Haskell,
>and then lambdas will probably make more sense.)

Having "lambda" and "def" as seperate (and slightly different)
ways to create a function adds to the confusion.

I think the best way of explaining lambda would be by saying that

      def foo(x,y,z):

      foo = lambda x,y,z: expression-involving-x,y,z

are identical.

The gotcha is that the body of a lambda can't be a statement,
only an expression.  But for that difference, lambda would be
easier to explain.

Grant Edwards                   grante             Yow!  RELATIVES!!

More information about the Python-list mailing list