Re: lambda a plusieurs arguments

Discussion in 'Python' started by Jp Calderone, May 27, 2005.

  1. Jp Calderone

    Jp Calderone Guest

    On Fri, 27 May 2005 19:38:33 +0200, nico <> 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
     
    Jp Calderone, May 27, 2005
    #1
    1. Advertising

  2. Jp Calderone

    nico Guest

    Jp Calderone wrote:

    > On Fri, 27 May 2005 19:38:33 +0200, nico <> 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
     
    nico, May 28, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roman Suzi
    Replies:
    13
    Views:
    608
    Bengt Richter
    Jan 7, 2005
  2. nico

    lambda a plusieurs arguments

    nico, May 27, 2005, in forum: Python
    Replies:
    2
    Views:
    348
  3. Paul Brannan

    lambda arguments in an extension

    Paul Brannan, Sep 12, 2007, in forum: Ruby
    Replies:
    0
    Views:
    89
    Paul Brannan
    Sep 12, 2007
  4. Steve Dogers

    lambda vs non-lambda proc

    Steve Dogers, Mar 30, 2009, in forum: Ruby
    Replies:
    1
    Views:
    178
    Sean O'Halpin
    Mar 30, 2009
  5. Haochen Xie
    Replies:
    4
    Views:
    245
    Haochen Xie
    Mar 17, 2013
Loading...

Share This Page