@@ -2834,14 +2834,19 @@ defmodule Enum do
28342834 end
28352835
28362836 @ doc """
2837- Applies the given function to each element in the `enumerable`,
2838- storing the result in a list and passing it as the accumulator
2839- for the next computation. Uses the first element in the `enumerable`
2840- as the starting value.
2837+ Passes each element from `enumerable` to the `fun` as the first argument,
2838+ stores the `fun` result in a list and passes the result as the second argument
2839+ for the next computation.
2840+
2841+ The `fun` isn't applied for the first element of the `enumerable`,
2842+ the element is taken as it is.
28412843
28422844 ## Examples
28432845
2844- iex> Enum.scan(1..5, &(&1 + &2))
2846+ iex> Enum.scan(["a", "b", "c", "d", "e"], fn element, acc -> element <> String.first(acc) end)
2847+ ["a", "ba", "cb", "dc", "ed"]
2848+
2849+ iex> Enum.scan(1..5, fn element, acc -> element + acc end)
28452850 [1, 3, 6, 10, 15]
28462851
28472852 """
@@ -2861,13 +2866,18 @@ defmodule Enum do
28612866 end
28622867
28632868 @ doc """
2864- Applies the given function to each element in the `enumerable`,
2865- storing the result in a list and passing it as the accumulator
2866- for the next computation. Uses the given `acc` as the starting value.
2869+ Passes each element from `enumerable` to the `fun` as the first argument,
2870+ stores the `fun` result in a list and passes the result as the second argument
2871+ for the next computation.
2872+
2873+ Passes the given `acc` as the second argument for the `fun` with the first element.
28672874
28682875 ## Examples
28692876
2870- iex> Enum.scan(1..5, 0, &(&1 + &2))
2877+ iex> Enum.scan(["a", "b", "c", "d", "e"], "_", fn element, acc -> element <> String.first(acc) end)
2878+ ["a_", "ba", "cb", "dc", "ed"]
2879+
2880+ iex> Enum.scan(1..5, 0, fn element, acc -> element + acc end)
28712881 [1, 3, 6, 10, 15]
28722882
28732883 """
0 commit comments