mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-25 00:06:47 +03:00
Merge pull request #2220 from Atcold/patch-1
Update python3.html.markdown
This commit is contained in:
commit
a7bbee6aa0
@ -589,10 +589,10 @@ add_10(3) # => 13
|
|||||||
|
|
||||||
# TODO - Fix for iterables
|
# TODO - Fix for iterables
|
||||||
# There are built-in higher order functions
|
# There are built-in higher order functions
|
||||||
map(add_10, [1, 2, 3]) # => [11, 12, 13]
|
list(map(add_10, [1, 2, 3])) # => [11, 12, 13]
|
||||||
map(max, [1, 2, 3], [4, 2, 1]) # => [4, 2, 3]
|
list(map(max, [1, 2, 3], [4, 2, 1])) # => [4, 2, 3]
|
||||||
|
|
||||||
filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7]
|
list(filter(lambda x: x > 5, [3, 4, 5, 6, 7])) # => [6, 7]
|
||||||
|
|
||||||
# We can use list comprehensions for nice maps and filters
|
# We can use list comprehensions for nice maps and filters
|
||||||
# List comprehension stores the output as a list which can itself be a nested list
|
# List comprehension stores the output as a list which can itself be a nested list
|
||||||
|
Loading…
Reference in New Issue
Block a user