From 9dca295c055502d333e2ab1f4a1f9ae6f39f4b9e Mon Sep 17 00:00:00 2001 From: Alfredo Canziani Date: Wed, 30 Mar 2016 11:17:12 -0400 Subject: Update python3.html.markdown `map` requires `list` in order to convert the mapping to its list. E.g. `` to `[11, 12, 13]`. --- python3.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python3.html.markdown b/python3.html.markdown index ea29fdba..7864ae3f 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -589,8 +589,8 @@ add_10(3) # => 13 # TODO - Fix for iterables # There are built-in higher order functions -map(add_10, [1, 2, 3]) # => [11, 12, 13] -map(max, [1, 2, 3], [4, 2, 1]) # => [4, 2, 3] +list(map(add_10, [1, 2, 3])) # => [11, 12, 13] +list(map(max, [1, 2, 3], [4, 2, 1])) # => [4, 2, 3] filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] -- cgit v1.2.3 From 6248cd1f84401548b80b48c9f1c4b55502c20095 Mon Sep 17 00:00:00 2001 From: Alfredo Canziani Date: Wed, 30 Mar 2016 11:24:05 -0400 Subject: Update python3.html.markdown The same happens for `filter`. ```pythob filter(lambda x: x > 5, [3, 4, 5, 6, 7]) list(filter(lambda x: x > 5, [3, 4, 5, 6, 7])) [6, 7] ``` --- python3.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python3.html.markdown b/python3.html.markdown index 7864ae3f..c2454076 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -592,7 +592,7 @@ add_10(3) # => 13 list(map(add_10, [1, 2, 3])) # => [11, 12, 13] 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 # List comprehension stores the output as a list which can itself be a nested list -- cgit v1.2.3