Skip to content

Commit 2c5650c

Browse files
author
José Valim
committed
Merge pull request #1926 from jwarwick/enum_docs
Fixing typos in Enum/Enumerable docs
2 parents 3776623 + f3ae3b0 commit 2c5650c

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

lib/elixir/lib/enum.ex

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ defprotocol Enumerable do
2727
The reason the accumulator requires a tagged tuple is to allow the
2828
reducer function to communicate to the underlying enumerable the end
2929
of enumeration, allowing any open resource to be properly closed. It
30-
also allows suspension of the enumeration, which is useful in case
31-
interleaving in between many enumerables are required (as in zip).
30+
also allows suspension of the enumeration, which is useful when
31+
interleaving between many enumerables is required (as in zip).
3232
3333
Finally, `Enumerable.reduce/3` will return another tagged tuple,
3434
as represented by the `result/0` type.
@@ -55,8 +55,8 @@ defprotocol Enumerable do
5555
@typedoc """
5656
The reducer function.
5757
58-
Should be called with the collection element, the
59-
accumulator contents and returns the accumulator for
58+
Should be called with the collection element and the
59+
accumulator contents. Returns the accumulator for
6060
the next enumeration step.
6161
"""
6262
@type reducer :: (term, term -> acc)
@@ -68,10 +68,10 @@ defprotocol Enumerable do
6868
its end, or *halted*/*suspended* when the enumeration was halted
6969
or suspended by the reducer function.
7070
71-
In case a reducer function returns `:suspend` accumulator, the
71+
In case a reducer function returns the `:suspend` accumulator, the
7272
`:suspended` tuple must be explicitly handled by the caller and
7373
never leak. In practice, this means regular enumeration functions
74-
just need to concern about `:done` and `:halted` results.
74+
just need to be concerned about `:done` and `:halted` results.
7575
7676
Furthermore, a `:suspend` call must always be followed by another call,
7777
eventually halting or continuing until the end.
@@ -81,7 +81,7 @@ defprotocol Enumerable do
8181
@typedoc """
8282
A partially applied reduce function.
8383
84-
The continuation is the closure returned as result when
84+
The continuation is the closure returned as a result when
8585
the enumeration is suspended. When invoked, it expects
8686
a new accumulator and it returns the result.
8787
@@ -97,7 +97,7 @@ defprotocol Enumerable do
9797
Reduces the collection into a value.
9898
9999
Most of the operations in `Enum` are implemented in terms of reduce.
100-
This function should simply apply the given `reducer` function to each
100+
This function should apply the given `reducer` function to each
101101
item in the collection and proceed as expected by the returned accumulator.
102102
103103
As an example, here is the implementation of `reduce` for lists:
@@ -148,7 +148,7 @@ defmodule Enum do
148148
iex> Enum.map(dict, fn { k, v } -> { k, v * 2 } end)
149149
[a: 2, b: 4]
150150
151-
Note the functions in the `Enum` module are eager: they always start
151+
Note that the functions in the `Enum` module are eager: they always start
152152
the enumeration of the given collection. The `Stream` module allows
153153
lazy enumeration of collections and provides infinite streams.
154154
@@ -316,7 +316,7 @@ defmodule Enum do
316316
from `pad` if it was passed. If `pad` is passed and does not
317317
have enough elements to fill the chunk, then the chunk is
318318
returned anyway with less than `n` elements. If `pad` is not
319-
passed at all or is nil, then the partial chunk is discarded
319+
passed at all or is `nil`, then the partial chunk is discarded
320320
from the result.
321321
322322
## Examples
@@ -389,7 +389,7 @@ defmodule Enum do
389389
@doc """
390390
Concatenates the enumerable on the right with the enumerable on the left.
391391
392-
This function produces the same result as the `++` operator for lists.
392+
This function produces the same result as the `Kernel.++/2` operator for lists.
393393
394394
## Examples
395395
@@ -760,7 +760,7 @@ defmodule Enum do
760760
end
761761

762762
@doc """
763-
Returns the first item in the collection or `nil` otherwise.
763+
Returns the first item in the collection or `nil` if the collection is empty.
764764
765765
## Examples
766766
@@ -784,7 +784,7 @@ defmodule Enum do
784784
Returns a new collection appending the result of invoking `fun`
785785
on each corresponding item of `collection`.
786786
787-
Given function should return a list.
787+
The given function should return a list.
788788
789789
## Examples
790790
@@ -805,7 +805,7 @@ defmodule Enum do
805805
end
806806

807807
@doc """
808-
Intersperses the `element` between each element of the enumeration.
808+
Intersperses `element` between each element of the enumeration.
809809
810810
Complexity: O(n)
811811
@@ -865,7 +865,7 @@ defmodule Enum do
865865
Returns a new collection, where each item is the result
866866
of invoking `fun` on each corresponding item of `collection`.
867867
868-
For dicts, the function accepts a key-value tuple.
868+
For dicts, the function expects a key-value tuple.
869869
870870
## Examples
871871
@@ -1227,7 +1227,7 @@ defmodule Enum do
12271227

12281228
@doc """
12291229
Applies the given function to each element in the collection,
1230-
storing the result in a list and passing it as accumulator
1230+
storing the result in a list and passing it as the accumulator
12311231
for the next computation.
12321232
12331233
## Examples
@@ -1245,8 +1245,8 @@ defmodule Enum do
12451245

12461246
@doc """
12471247
Applies the given function to each element in the collection,
1248-
storing the result in a list and passing it as accumulator
1249-
for the next computation. Uses the given `acc` as starting value.
1248+
storing the result in a list and passing it as the accumulator
1249+
for the next computation. Uses the given `acc` as the starting value.
12501250
12511251
## Examples
12521252
@@ -1264,7 +1264,7 @@ defmodule Enum do
12641264
@doc """
12651265
Returns a list of collection elements shuffled.
12661266
1267-
Notice you need to explicitly call `:random.seed/1` and
1267+
Notice that you need to explicitly call `:random.seed/1` and
12681268
set a seed value for the random algorithm. Otherwise, the
12691269
default seed will be set which will always return the same
12701270
result. For example, one could do the following to set a seed
@@ -1385,7 +1385,9 @@ defmodule Enum do
13851385
end
13861386

13871387
@doc """
1388-
Returns a sorted list of collection elements. Uses the merge sort algorithm.
1388+
Returns a list of collection elements sorted by the given function.
1389+
1390+
Uses the merge sort algorithm.
13891391
13901392
## Examples
13911393
@@ -1521,8 +1523,8 @@ defmodule Enum do
15211523
end
15221524

15231525
@doc """
1524-
Returns a collection of every `nth` items in the collection,
1525-
starting with the first.
1526+
Returns a collection of every `nth` item in the collection,
1527+
starting with the first element.
15261528
15271529
## Examples
15281530

0 commit comments

Comments
 (0)