From 9e777b0957edb2af05bdeecfee4a308f4cf41ab4 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 17 Mar 2015 19:26:13 -0400 Subject: [PATCH] Note possible reuse of return values of map function for mapreduce [ci skip] --- doc/stdlib/collections.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/stdlib/collections.rst b/doc/stdlib/collections.rst index 385c9b1eea3de..5fd4d013543d5 100644 --- a/doc/stdlib/collections.rst +++ b/doc/stdlib/collections.rst @@ -464,16 +464,18 @@ Iterable Collections :func:`mapreduce` is functionally equivalent to calling ``reduce(op, v0, map(f, itr))``, but will in general execute faster since no intermediate collection needs to be created. See documentation for - :func:`reduce` and ``map``. + :func:`reduce` and :func:`map`. .. doctest:: julia> mapreduce(x->x^2, +, [1:3]) # == 1 + 4 + 9 14 - The associativity of the reduction is implementation-dependent. Use - :func:`mapfoldl` or :func:`mapfoldr` instead for guaranteed left or - right associativity. + The associativity of the reduction is implementation-dependent. + Additionally, some implementations may reuse the return value of + ``f`` for elements that appear multiple times in ``itr``. + Use :func:`mapfoldl` or :func:`mapfoldr` instead for guaranteed + left or right associativity and invocation of ``f`` for every value. .. function:: mapreduce(f, op, itr)