Re: fun with lambdas

2005-10-21 Thread Juan Pablo Romero
Thanks to all I settled with this: def partial1(f,b): return lambda a:f(a,b) def partial2(f,a): return lambda b:f(a,b) Juan Pablo 2005/10/20, Mike Meyer [EMAIL PROTECTED]: Robert Kern [EMAIL PROTECTED] writes: Juan Pablo Romero wrote: Hello! given the definition

fun with lambdas

2005-10-20 Thread Juan Pablo Romero
Hello! given the definition def f(a,b): return a+b With this code: fs = [ lambda x: f(x,o) for o in [0,1,2]] or this fs = [] for o in [0,1,2]: fs.append( lambda x: f(x,o) ) I'd expect that fs contains partial evaluated functions, i.e. fs[0](0) == 0 fs[1](0) == 1 fs[2](0) == 2 But this

Re: fun with lambdas

2005-10-20 Thread Robert Kern
Juan Pablo Romero wrote: Hello! given the definition def f(a,b): return a+b With this code: fs = [ lambda x: f(x,o) for o in [0,1,2]] or this fs = [] for o in [0,1,2]: fs.append( lambda x: f(x,o) ) I'd expect that fs contains partial evaluated functions, i.e.

Re: fun with lambdas

2005-10-20 Thread [EMAIL PROTECTED]
You are asking it to return a list of lambda, not its evaluated value. map(lambda x: f(x,0), [0,1,2]) works. [ f(o) for o in [0,1,2] ] works too. Juan Pablo Romero wrote: Hello! given the definition def f(a,b): return a+b With this code: fs = [ lambda x: f(x,o) for o in [0,1,2]] or

Re: fun with lambdas

2005-10-20 Thread Mike Meyer
Robert Kern [EMAIL PROTECTED] writes: Juan Pablo Romero wrote: Hello! given the definition def f(a,b): return a+b With this code: fs = [ lambda x: f(x,o) for o in [0,1,2]] or this fs = [] for o in [0,1,2]: fs.append( lambda x: f(x,o) ) I'd expect that fs contains