ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 23 Jan 2019 16:08:06 +0100Difference between def and lambda Function declarationhttps://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/ Here is an example. Is There any difference?
https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/algebra/algebra1.sagews?viewer=shareMon, 21 Jan 2019 14:44:40 +0100https://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/Comment by slelievre for <p>Here is an example. Is There any difference?
<a href="https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/algebra/algebra1.sagews?viewer=share">https://share.cocalc.com/share/a3f14e...</a></p>
https://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/?comment=45152#post-id-45152There does not seem to be anything at the end of the link you provided.Wed, 23 Jan 2019 16:08:06 +0100https://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/?comment=45152#post-id-45152Answer by tmonteil for <p>Here is an example. Is There any difference?
<a href="https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/algebra/algebra1.sagews?viewer=share">https://share.cocalc.com/share/a3f14e...</a></p>
https://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/?answer=45128#post-id-45128I am sorry that i can not access to the cocalc file. The difference is basically that a lambda function is anonymous: you do not need to give it a name to use it in a function.
For example, if a function named `foo` takes a function as input, you can do:
def f(x):
return blah
foo(f)
or
foo(lambda x : blah)
In the first construction, you have to give the name f to define the function, in the second case, you can pass the function to `foo` without having to give it a name first.
Mon, 21 Jan 2019 15:43:48 +0100https://ask.sagemath.org/question/45123/difference-between-def-and-lambda-function-declaration/?answer=45128#post-id-45128