Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcf9468

Browse files
committed
Update lambda description to reflect nested scopes. This was noted by
Andrew Koenig.
1 parent 1a76386 commit fcf9468

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Doc/tut/tut.tex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,19 +1535,17 @@ \subsection{Lambda Forms \label{lambda}}
15351535
objects are required. They are syntactically restricted to a single
15361536
expression. Semantically, they are just syntactic sugar for a normal
15371537
function definition. Like nested function definitions, lambda forms
1538-
cannot reference variables from the containing scope, but this can be
1539-
overcome through the judicious use of default argument values:
1538+
can reference variables from the containing scope:
15401539

15411540
\begin{verbatim}
15421541
>>> def make_incrementor(n):
1543-
... return lambda x, incr=n: x+incr
1542+
... return lambda x: x + n
15441543
...
15451544
>>> f = make_incrementor(42)
15461545
>>> f(0)
15471546
42
15481547
>>> f(1)
15491548
43
1550-
>>>
15511549
\end{verbatim}
15521550

15531551

0 commit comments

Comments
 (0)