@@ -22,9 +22,8 @@ The tools are designed to combine readily with one another. This makes it easy
2222to construct more specialized tools succinctly and efficiently in pure Python.
2323
2424For instance, SML provides a tabulation tool: ``tabulate(f) `` which produces a
25- sequence ``f(0), f(1), ... ``. This toolbox provides :func: `imap ` and
26- :func: `count ` which can be combined to form ``imap(f, count()) `` and produce an
27- equivalent result.
25+ sequence ``f(0), f(1), ... ``. But, this effect can be achieved in Python
26+ by combining :func: `map ` and :func: `count ` to form ``map(f, count()) ``.
2827
2928Likewise, the functional tools are designed to work well with the high-speed
3029functions provided by the :mod: `operator ` module.
@@ -138,7 +137,7 @@ loops that truncate the stream.
138137.. function :: count([n])
139138
140139 Make an iterator that returns consecutive integers starting with *n *. If not
141- specified *n * defaults to zero. Often used as an argument to :func: `imap ` to
140+ specified *n * defaults to zero. Often used as an argument to :func: `map ` to
142141 generate consecutive data points. Also, used with :func: `izip ` to add sequence
143142 numbers. Equivalent to::
144143
@@ -248,22 +247,6 @@ loops that truncate the stream.
248247 yield x
249248
250249
251- .. function :: imap(function, *iterables)
252-
253- Make an iterator that computes the function using arguments from each of the
254- iterables. This function is the same as the built-in :func: `map ` function.
255- Equivalent to::
256-
257- def imap(function, *iterables):
258- iterables = [iter(it) for it in iterables)
259- while True:
260- args = [next(it) for it in iterables]
261- if function is None:
262- yield tuple(args)
263- else:
264- yield function(*args)
265-
266-
267250.. function :: islice(iterable, [start,] stop [, step])
268251
269252 Make an iterator that returns selected elements from the iterable. If *start * is
@@ -421,7 +404,7 @@ loops that truncate the stream.
421404.. function :: repeat(object[, times])
422405
423406 Make an iterator that returns *object * over and over again. Runs indefinitely
424- unless the *times * argument is specified. Used as argument to :func: `imap ` for
407+ unless the *times * argument is specified. Used as argument to :func: `map ` for
425408 invariant parameters to the called function. Also used with :func: `izip ` to
426409 create an invariant part of a tuple record. Equivalent to::
427410
@@ -437,9 +420,9 @@ loops that truncate the stream.
437420.. function :: starmap(function, iterable)
438421
439422 Make an iterator that computes the function using arguments obtained from
440- the iterable. Used instead of :func: `imap ` when argument parameters are already
423+ the iterable. Used instead of :func: `map ` when argument parameters are already
441424 grouped in tuples from a single iterable (the data has been "pre-zipped"). The
442- difference between :func: `imap ` and :func: `starmap ` parallels the distinction
425+ difference between :func: `map ` and :func: `starmap ` parallels the distinction
443426 between ``function(a,b) `` and ``function(*c) ``. Equivalent to::
444427
445428 def starmap(function, iterable):
@@ -507,7 +490,7 @@ can be combined. ::
507490 Check 1202 is for $823.14
508491
509492 >>> import operator
510- >>> for cube in imap (operator.pow, range(1,5), repeat(3)):
493+ >>> for cube in map (operator.pow, range(1,5), repeat(3)):
511494 ... print(cube)
512495 ...
513496 1
@@ -577,7 +560,7 @@ which incur interpreter overhead. ::
577560
578561 def tabulate(function):
579562 "Return function(0), function(1), ..."
580- return imap (function, count())
563+ return map (function, count())
581564
582565 def nth(iterable, n):
583566 "Returns the nth item or raise StopIteration"
@@ -603,7 +586,7 @@ which incur interpreter overhead. ::
603586
604587 def quantify(seq, pred=None):
605588 "Count how many times the predicate is true in the sequence"
606- return sum(imap (pred, seq))
589+ return sum(map (pred, seq))
607590
608591 def padnone(seq):
609592 """Returns the sequence elements and then returns None indefinitely.
@@ -617,7 +600,7 @@ which incur interpreter overhead. ::
617600 return chain.from_iterable(repeat(seq, n))
618601
619602 def dotproduct(vec1, vec2):
620- return sum(imap (operator.mul, vec1, vec2))
603+ return sum(map (operator.mul, vec1, vec2))
621604
622605 def flatten(listOfLists):
623606 return list(chain.from_iterable(listOfLists))
0 commit comments