@@ -3924,8 +3924,9 @@ defmodule Enum do
39243924 If an integer offset is given as `fun_or_offset`, it will index from the given
39253925 offset instead of from zero.
39263926
3927- If a function is given as `fun_or_offset`, it will index by invoking the function
3928- for each element and index (zero-based) of the enumerable.
3927+ If a 2-arity function is given as `fun_or_offset`, the function will be invoked
3928+ for each element in `enumerable` as the first argument and with a zero-based
3929+ index as the second. `with_index/2` returns a list with the result of each invocation.
39293930
39303931 ## Examples
39313932
@@ -4036,10 +4037,10 @@ defmodule Enum do
40364037 key in the left map and the matching key in the right map, but there is no such
40374038 guarantee because map keys are not ordered! Consider the following:
40384039
4039- left = %{:a => 1, 1 => 3}
4040+ left = %{:a => 1, 1 => 3}
40404041 right = %{:a => 1, :b => :c}
40414042 Enum.zip(left, right)
4042- # [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
4043+ #=> [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
40434044
40444045 As you can see `:a` does not get paired with `:a`. If this is what you want,
40454046 you should use `Map.merge/3`.
@@ -4112,8 +4113,11 @@ defmodule Enum do
41124113 iex> Enum.zip_reduce([1, 2], [3, 4], 0, fn x, y, acc -> x + y + acc end)
41134114 10
41144115
4115- iex> Enum.zip_reduce([1, 2], [3, 4], [], fn x, y, acc -> [x + y | acc] end)
4116- [6, 4]
4116+ If one of the lists has more entries than the others,
4117+ those entries are discarded:
4118+
4119+ iex> Enum.zip_reduce([1, 2, 3], [4, 5], [], fn x, y, acc -> [x + y | acc] end)
4120+ [7, 5]
41174121 """
41184122 @ doc since: "1.12.0"
41194123 @ spec zip_reduce ( t , t , acc , ( enum1_elem :: term , enum2_elem :: term , acc -> acc ) ) :: acc
@@ -4149,7 +4153,10 @@ defmodule Enum do
41494153 ...> end)
41504154 [{1, 2, 3}, {1, 2, 3}]
41514155
4152- iex> enums = [[1, 2], [a: 3, b: 4], [5, 6]]
4156+ If one of the lists has more entries than the others,
4157+ those entries are discarded:
4158+
4159+ iex> enums = [[1, 2], [a: 3, b: 4], [5, 6, 7]]
41534160 ...> Enum.zip_reduce(enums, [], fn elements, acc ->
41544161 ...> [List.to_tuple(elements) | acc]
41554162 ...> end)
0 commit comments