From 90b182c16c2e9ccf238dde897ff9434570f8da7b Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Thu, 14 Aug 2003 22:57:46 +0000 Subject: [PATCH] Don't introduce map(None, ...) in the tutorial. In practice, zip() is usually preferred. --- Doc/tut/tut.tex | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index 1dcf5c3ebc2..949f703bea3 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