?
=?ISO-8859-1?Q?Xavier_D=E9coret?=
Hi,
I cannot find the way to do generic lambda functions using the lambda
syntax in python. I am probably missing a point.
For example, the code
# f = lambda : print "hello"
# f()
does not compile, although:
# def f():
# print "hello"
# f()
does compile. Is there a particular syntax for lambda that I am missing
or is it simply limited and I cannot do what I want with lambda.
In the same spirit, how can I do to compute intermediary values in the
body of a lambda function. Let's say (dummy example):
f = lambda x : y=x*x,y+y
In languages like Caml, you can do:
let f = function x -> let y=x*x in y+y;;
Does the lambda : syntax in python allow for the same kind of constructs?
Thanks.
I cannot find the way to do generic lambda functions using the lambda
syntax in python. I am probably missing a point.
For example, the code
# f = lambda : print "hello"
# f()
does not compile, although:
# def f():
# print "hello"
# f()
does compile. Is there a particular syntax for lambda that I am missing
or is it simply limited and I cannot do what I want with lambda.
In the same spirit, how can I do to compute intermediary values in the
body of a lambda function. Let's say (dummy example):
f = lambda x : y=x*x,y+y
In languages like Caml, you can do:
let f = function x -> let y=x*x in y+y;;
Does the lambda : syntax in python allow for the same kind of constructs?
Thanks.