Skip to content

Commit b5f4caf

Browse files
committed
whatever code for lambdas
1 parent 347c99e commit b5f4caf

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

doc/Language/py-nutshell.pod6

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,23 @@ Perl 6
171171
say x;
172172
# x is 10
173173
174-
Lambdas in Python can be written as pointy blocks in Perl 6.
174+
Lambdas in Python are equivalent to anonymous subroutines in Perl 6.
175+
One way to write them is as pointy blocks.
175176
176177
Python
177-
l = lambda i: i * n
178+
l = lambda i: i + 12
178179
Perl 6
179-
$l = -> $i { $i * $n }
180+
$l = -> $i { $i + 12 }
180181
181-
Pointy blocks (like all blocks) have their own scope.
182+
Another Perl 6 idiom for constructing lambdas is the Whatever code, C<*>.
183+
A C<*> can be used in an expression to indicate that the expression is a
184+
block, and that the C<*> should be replaced by the first parameter to
185+
the block.
186+
187+
Perl 6
188+
$l = * + 12
189+
190+
See the section below for more constructs.
182191
183192
Another example (from the Python L<FAQ|https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result>):
184193

0 commit comments

Comments
 (0)