Lambda Forms Question

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Wed Oct 18 20:26:24 EDT 2000


You do it pretty much like in Scheme, you have to evaluate the function
object:

>>> (lambda x: x * x) (4)
16
>>> func = (lambda x: x * x)
>>> func ( 15 )
225


--
----------------------------------------------------------------------
Olivier A. Dagenais - Software Architect and Developer
"Someone called 'Type your name here' is impersonating me on the
internet and is posting exactly the same things I am posting!"


"Scott Weisel" <sweisel at drew.edu> wrote in message
news:39EE3CC1.E2B07AB7 at drew.edu...
> I'm working with Python on a school project and while I was reading the
> documentation I was quite surprised to find out that Python has some
> features of Lisp.  Since we're using Scheme, a variant of Lisp in class, I
> was hoping to use the Lisp feature in Python, but I'm having trouble
> implementing it.
>
> The example that the online documentation gives is
> def make_incrementor(n):
>          return lambda x, incr=n: x+incr
> which returns a function.  Is there any way to write the program so a
value
> is returned, rather than a function.
>
> Also, how do I write the functions by themselves.  I wrote
> lambda x: x*x
> but I have no way to call it.
>
> Any advice would be appreciated
> Thanks in advance
> -Scott





More information about the Python-list mailing list