First time here? Check out the FAQ!

Ask Your Question
0

I am a total newbie (and don't apologize for it!) What does the operator "lambda" do? What does it mean?

asked 10 years ago

cltho2 gravatar image

I am a total newbie (and don't apologize for it!) What does the operator "lambda" do? What does it mean?

Preview: (hide)

Comments

You should shorten your title to ease readability of asksage (as such it looks like spam).

tmonteil gravatar imagetmonteil ( 10 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 10 years ago

tmonteil gravatar image

Short answer : lambda is used to create short and anonymous Python functions. For example, instead of writing:

sage: def inc(n):
....:     return n+1

You can write:

 sage: inc = lambda x : x+1

but lambda x : x+1 can be used directly in your code, without needing to name it inc, while the def construction require to give a name and use return

Longer answer : http://www.sagemath.org/doc/thematic_...

Preview: (hide)
link
0

answered 10 years ago

kcrisman gravatar image

To answer an implicit question of why you might use them, sometimes there are functions you want to do something with in Sage that are not symbolic - see e.g. this documentation or here.

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 10 years ago

Seen: 557 times

Last updated: Dec 15 '14