Ask Your Question
0

Difference between def and lambda Function declaration

asked 2019-01-21 07:44:40 -0500

thetha gravatar image

Here is an example. Is There any difference? https://share.cocalc.com/share/a3f14e...

edit retag flag offensive close merge delete

Comments

There does not seem to be anything at the end of the link you provided.

slelievre gravatar imageslelievre ( 2019-01-23 09:08:06 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-01-21 08:43:48 -0500

tmonteil gravatar image

I 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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-01-21 07:44:40 -0500

Seen: 41 times

Last updated: Jan 21