What is not allowed in a lamba expression? (what type of statements?)
Answer
Assignment and control statements are not allowed.
Tags
#python #sicp
Question
What is not allowed in a lamba expression? (what type of statements?)
Answer
?
Tags
#python #sicp
Question
What is not allowed in a lamba expression? (what type of statements?)
Answer
Assignment and control statements are not allowed.
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it b or c*d , or the full expression.
In Python, we can create function values on the fly using lambda expressions, which evaluate to unnamed functions. A lambda expression evaluates
to a function that has a single return expression as its body. <span>Assignment and
control statements are not allowed.<span><body><html>
Original toplevel document
1.6 Higher-Order Functions
1.6.7 Lambda Expressions
Video:
Show
Hide So far, each time we have wanted to define a new function, we needed to give it
a name. But for other types of expressions, we don't need to associate
intermediate values with a name. That is, <span>we can compute a*b + c*d without
having to name the subexpressions a*b or c*d , or the full expression.
In Python, we can create function values on the fly using lambda
expressions, which evaluate to unnamed functions. A lambda expression evaluates
to a function that has a single return expression as its body. Assignment and
control statements are not allowed.
>>> def compose1(f, g):
return lambda x: f(g(x))
We can understand the structure of a lambda expression by constructing a
corresponding English sentence:
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.