# [Python-3000] lambda

Neil Toronto ntoronto at cs.byu.edu
Thu Mar 27 17:19:12 CET 2008

```Olivier Verdier wrote:
> On 26/03/2008, *Nick Coghlan* <ncoghlan at gmail.com
>     Lambda calculus is a
>     well established field of mathematics, so it's a perfectly valid name
>     for the construct.
>
> In my university in Sweden lambda calculus is never taught neither in
> pure nor applied math. It is only a part of a course in computer science
> applied to linguistics. The word "lambda" however is  used all over the
> place as an eigenvalue, or a wave length, or parameter, or Lamé
> coefficient in many of our courses.

Yep. In my seven years of CS instruction so far, I've only come across
this once, in a theory of programming languages course. "Lambda" simply
doesn't show up unless you do language theory or program in a Lisp... or
in Python.

> I also agree with the idea that the lambda construct should rather use a
> keyword free syntax like "x -> 3*x" or something of that kind. That
> would be gorgeous.

How about reusing "def" to make a lambda expression?

f = def x, y: x**2 + y**2

or

f = def(x, y): x**2 + y**2

By the time someone comes across this:

map(def(x): x**2, lst)

in code, they've already created plenty of functions using "def", so it
should be immediately obvious what it's doing. It's a little less terse
than Haskell's "\->" or Greg's "=>", but not much. It also frees up a
keyword and doesn't create a new operator-ish looking one. Lastly, I
can't imagine that it would be *too* difficult to parse, especially the
variation with parenthesis.

Neil

```