diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2003-08-14 22:57:46 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2003-08-14 22:57:46 (GMT) |
commit | 90b182c16c2e9ccf238dde897ff9434570f8da7b (patch) | |
tree | 32ec9229c7b550cb7602bb0099bad77c58534b47 /Doc/tut | |
parent | e98147a8e553a7b653cd2154403f914c1589857e (diff) | |
download | cpython-90b182c16c2e9ccf238dde897ff9434570f8da7b.zip cpython-90b182c16c2e9ccf238dde897ff9434570f8da7b.tar.gz cpython-90b182c16c2e9ccf238dde897ff9434570f8da7b.tar.bz2 |
Don't introduce map(None, ...) in the tutorial. In practice, zip() is
usually preferred.
Diffstat (limited to 'Doc/tut')
-rw-r--r-- | Doc/tut/tut.tex | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index 1dcf5c3..949f703 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -1836,19 +1836,14 @@ cubes: More than one sequence may be passed; the function must then have as many arguments as there are sequences and is called with the corresponding item from each sequence (or \code{None} if some sequence -is shorter than another). If \code{None} is passed for the function, -a function returning its argument(s) is substituted. - -Combining these two special cases, we see that -\samp{map(None, \var{list1}, \var{list2})} is a convenient way of -turning a pair of lists into a list of pairs. For example: +is shorter than another). For example: \begin{verbatim} >>> seq = range(8) ->>> def square(x): return x*x +>>> def add(x, y): return x+y ... ->>> map(None, seq, map(square, seq)) -[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36), (7, 49)] +>>> map(add, seq, seq) +[0, 2, 4, 6, 8, 10, 12, 14] \end{verbatim} \samp{reduce(\var{func}, \var{sequence})} returns a single value |