-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Enum scan improvements #14486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enum scan improvements #14486
Changes from 2 commits
5598b05
c006c92
3589746
78fe023
f7e1380
538da73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2864,13 +2864,16 @@ defmodule Enum do | |
| end | ||
|
|
||
| @doc """ | ||
| Applies the given function to each element in the `enumerable`, | ||
| storing the result in a list and passing it as the accumulator | ||
| for the next computation. Uses the first element in the `enumerable` | ||
| as the starting value. | ||
| Passes each element from `enumerable` to the `fun` as the first argument, | ||
| stores the `fun` result in a list and passes the result as the second argument | ||
| for the next computation. The `fun` isn't applied for the first element | ||
| of the `enumerable`, the element is taken as it is. | ||
|
|
||
| ## Examples | ||
|
|
||
| iex> Enum.scan(["a", "b", "c", "d", "e"], &(&1 <> String.first(&2))) | ||
|
||
| ["a", "ba", "cb", "dc", "ed"] | ||
|
|
||
| iex> Enum.scan(1..5, &(&1 + &2)) | ||
| [1, 3, 6, 10, 15] | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.