Velocity Reviews > Re: lambda a plusieurs arguments

# Re: lambda a plusieurs arguments

Jp Calderone
Guest
Posts: n/a

 05-27-2005
On Fri, 27 May 2005 19:38:33 +0200, nico <(E-Mail Removed)> wrote:
>Bonjour,
>
>Comment faire une fonction lambda a plusieurs arguments ?
>
>>>> (lambda a:a+1)(2)

>3
>>>> f=(lambda (a,b):a+b)
>>>> f(5,6)

>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>TypeError: <lambda>() takes exactly 1 argument (2 given)
>>>> f((5.6))

^--- ,

>>> f((5, 6))

11
>>>

Aussi,

>>> f = lambda a, b: a + b
>>> f(5, 6)

11
>>>

Jp

nico
Guest
Posts: n/a

 05-28-2005
Jp Calderone wrote:

> On Fri, 27 May 2005 19:38:33 +0200, nico <(E-Mail Removed)> wrote:
>>Bonjour,
>>
>>Comment faire une fonction lambda a plusieurs arguments ?
>>
>>>>> (lambda a:a+1)(2)

>>3
>>>>> f=(lambda (a,b):a+b)
>>>>> f(5,6)

>>Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>>TypeError: <lambda>() takes exactly 1 argument (2 given)
>>>>> f((5.6))

> ^--- ,
>
> >>> f((5, 6))

> 11
> >>>

>
> Aussi,
>
> >>> f = lambda a, b: a + b
> >>> f(5, 6)

> 11
> >>>

>
> Jp

Ok, merci.

--
nico