Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well, my try to work with dummy variables failed, but the code below solved the problem carefully: using the Lambda operator! var('x,y,z') f=function('f1', x,y) h= lambda function1,function2: integral(function1(x,y)*function2(x,z),x,-oo,oo) eq1= f1(y,z)==h(f1,f1) show(eq1) However, when I want to define other lambda operators e.g. in one variable it gives back an error that <lambda>() takes exactly 2 arguments (1 given), and this makes things hard as I need many of such operators defined in my work!

Well, my try to work with dummy variables failed, but the code below solved the problem carefully: using the Lambda operator! operator!

var('x,y,z')
f=function('f1', x,y)
h= lambda function1,function2: integral(function1(x,y)*function2(x,z),x,-oo,oo)
eq1= f1(y,z)==h(f1,f1)
show(eq1)

However, when I want to define other lambda operators e.g. in one variable it gives back an error that <lambda>() takes exactly 2 arguments (1 given), and this makes things hard as I need many of such operators defined in my work!

Well, my try tries to work with dummy variables failed, but the code below solved the problem carefully: using the Lambda operator!operator! Actually, it is also commented in the book "Dive into Python" that "You can use a lambda function without even assigning it to a variable" and this was what I exactly needed, not in defining my functions but in defining the operators acting on them, at least I guess so!

var('x,y,z')
f=function('f1', x,y)
h= lambda function1,function2: integral(function1(x,y)*function2(x,z),x,-oo,oo)
eq1= f1(y,z)==h(f1,f1)
show(eq1)

However, when I want to define other lambda operators e.g. in one variable it gives back an error that <lambda>() takes exactly 2 arguments (1 given), and this makes things hard as I need many of such operators defined in my work!

In the same book it was commented that "lambda functions are a matter of style. Using them is never required; anywhere you could use them, you could define a separate normal function and use that instead." However, I couldn't define another function doing so!?

Any idea?

Well, my tries to work with dummy variables failed, but the code below solved the problem carefully: using the Lambda operator! Actually, it is also commented in the book "Dive into Python" that "You can use a lambda function without even assigning it to a variable" and this was what I exactly needed, not in defining my functions but in defining the operators acting on them, at least I guess so!

var('x,y,z')
f=function('f1', x,y)
h= lambda function1,function2: integral(function1(x,y)*function2(x,z),x,-oo,oo)
eq1= f1(y,z)==h(f1,f1)
show(eq1)

However, when I want to define other lambda operators e.g. in one variable it gives back an error that <lambda>() takes exactly 2 arguments (1 given), and this makes things hard as I need many of such operators defined in my work!

In the same book it was commented that "lambda functions are a matter of style. Using them is never required; anywhere you could use them, you could define a separate normal function and use that instead." However, So that, it shouldn't be the only way, but I couldn't define another function doing so!?that does the same anyhow!?

Any idea?