Content deleted Content added
m Removed link to "Java limitations", section was removed long ago |
m →Higher-order functions: format code |
||
Line 124:
<syntaxhighlight lang="python">
>>> a = [1, 2, 3, 4, 5, 6]
>>> list(map(lambda x: x * x, a))
[1, 4, 9, 16, 25, 36]
</syntaxhighlight>
Line 132:
<syntaxhighlight lang="python">
>>> a = [1, 2, 3, 4, 5, 6]
>>> [x * x for x in a]
[1, 4, 9, 16, 25, 36]
</syntaxhighlight>
Line 163:
>>> from functools import reduce
>>> a = [1, 2, 3, 4, 5]
>>> reduce(lambda x, y: x * y, a)
120
</syntaxhighlight>
|