Skip to content

Commit 78fe023

Browse files
Fixes for Enum.scan/3
1 parent 3589746 commit 78fe023

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/elixir/lib/enum.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,11 +2896,15 @@ defmodule Enum do
28962896
end
28972897

28982898
@doc """
2899-
Applies the given function to each element in the `enumerable`,
2900-
storing the result in a list and passing it as the accumulator
2901-
for the next computation. Uses the given `acc` as the starting value.
2899+
Passes each element from `enumerable` to the `fun` as the first argument,
2900+
stores the `fun` result in a list and passes the result as the second argument
2901+
for the next computation.
2902+
2903+
Passes the given `acc` as the second argument for the `fun` with the first element.
29022904
29032905
## Examples
2906+
iex> Enum.scan(["a", "b", "c", "d", "e"], "_", &(&1 <> String.first(&2)))
2907+
["a_", "ba", "cb", "dc", "ed"]
29042908
29052909
iex> Enum.scan(1..5, 0, &(&1 + &2))
29062910
[1, 3, 6, 10, 15]

0 commit comments

Comments
 (0)