Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ defmodule Application do
invoked if it hasn't been done yet. Then, it checks if the dependencies listed
in the `applications` key of the resource file are already started. Having at
least one dependency not started is an error condition. Functions like
`ensure_all_started/1` takes care of starting an application and all of its
`ensure_all_started/1` take care of starting an application and all of its
dependencies for you.

If the application does not have a callback module configured, starting is
Expand Down
11 changes: 7 additions & 4 deletions lib/elixir/lib/enum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking we should use fn elem, acc -> in those examples for clarity. WDYT?

Copy link
Contributor Author

@dmitrykleymenov dmitrykleymenov May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and even my first attempt was to do so, and I think in the new example & is ok, but for existed one fn version seemed better, since + isn't affected by the order of arguments and it's better to explicitly point out where acc and element are

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we general we should prefer fn for documentation, in case someone is new to the language and they have not mastered the & notation yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, will back with changes

["a", "ba", "cb", "dc", "ed"]

iex> Enum.scan(1..5, &(&1 + &2))
[1, 3, 6, 10, 15]

Expand Down