@@ -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. The result of the invocation will be listed.
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- right = %{:a => 1, :b => :c}
4041- Enum.zip(left, right)
4042- # [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
4040+ iex> left = %{:a => 1, 1 => 3}
4041+ iex> right = %{:a => 1, :b => :c}
4042+ iex> Enum.zip(left, right)
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`.
@@ -4109,11 +4110,11 @@ defmodule Enum do
41094110
41104111 ## Examples
41114112
4112- iex> Enum.zip_reduce([1, 2], [3, 4], 0, fn x, y, acc -> x + y + acc end)
4113+ iex> Enum.zip_reduce([1, 2], [3, 4, 5 ], 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+ iex> Enum.zip_reduce([1, 2, 3], [4, 5 ], [], fn x, y, acc -> [x + y | acc] end)
4117+ [7, 5 ]
41174118 """
41184119 @ doc since: "1.12.0"
41194120 @ spec zip_reduce ( t , t , acc , ( enum1_elem :: term , enum2_elem :: term , acc -> acc ) ) :: acc
@@ -4143,13 +4144,13 @@ defmodule Enum do
41434144
41444145 ## Examples
41454146
4146- iex> enums = [[1, 1], [2, 2], [3, 3]]
4147+ iex> enums = [[1, 1, 1, 1 ], [2, 2, 2], [3, 3]]
41474148 ...> Enum.zip_reduce(enums, [], fn elements, acc ->
41484149 ...> [List.to_tuple(elements) | acc]
41494150 ...> end)
41504151 [{1, 2, 3}, {1, 2, 3}]
41514152
4152- iex> enums = [[1, 2], [a: 3, b: 4], [5, 6]]
4153+ iex> enums = [[1, 2], [a: 3, b: 4], [5, 6, 7 ]]
41534154 ...> Enum.zip_reduce(enums, [], fn elements, acc ->
41544155 ...> [List.to_tuple(elements) | acc]
41554156 ...> end)
0 commit comments