@@ -27,8 +27,8 @@ defprotocol Enumerable do
27
27
The reason the accumulator requires a tagged tuple is to allow the
28
28
reducer function to communicate to the underlying enumerable the end
29
29
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).
32
32
33
33
Finally, `Enumerable.reduce/3` will return another tagged tuple,
34
34
as represented by the `result/0` type.
@@ -55,8 +55,8 @@ defprotocol Enumerable do
55
55
@ typedoc """
56
56
The reducer function.
57
57
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
60
60
the next enumeration step.
61
61
"""
62
62
@ type reducer :: ( term , term -> acc )
@@ -68,10 +68,10 @@ defprotocol Enumerable do
68
68
its end, or *halted*/*suspended* when the enumeration was halted
69
69
or suspended by the reducer function.
70
70
71
- In case a reducer function returns `:suspend` accumulator, the
71
+ In case a reducer function returns the `:suspend` accumulator, the
72
72
`:suspended` tuple must be explicitly handled by the caller and
73
73
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.
75
75
76
76
Furthermore, a `:suspend` call must always be followed by another call,
77
77
eventually halting or continuing until the end.
@@ -81,7 +81,7 @@ defprotocol Enumerable do
81
81
@ typedoc """
82
82
A partially applied reduce function.
83
83
84
- The continuation is the closure returned as result when
84
+ The continuation is the closure returned as a result when
85
85
the enumeration is suspended. When invoked, it expects
86
86
a new accumulator and it returns the result.
87
87
@@ -97,7 +97,7 @@ defprotocol Enumerable do
97
97
Reduces the collection into a value.
98
98
99
99
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
101
101
item in the collection and proceed as expected by the returned accumulator.
102
102
103
103
As an example, here is the implementation of `reduce` for lists:
@@ -148,7 +148,7 @@ defmodule Enum do
148
148
iex> Enum.map(dict, fn { k, v } -> { k, v * 2 } end)
149
149
[a: 2, b: 4]
150
150
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
152
152
the enumeration of the given collection. The `Stream` module allows
153
153
lazy enumeration of collections and provides infinite streams.
154
154
@@ -316,7 +316,7 @@ defmodule Enum do
316
316
from `pad` if it was passed. If `pad` is passed and does not
317
317
have enough elements to fill the chunk, then the chunk is
318
318
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
320
320
from the result.
321
321
322
322
## Examples
@@ -389,7 +389,7 @@ defmodule Enum do
389
389
@ doc """
390
390
Concatenates the enumerable on the right with the enumerable on the left.
391
391
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.
393
393
394
394
## Examples
395
395
@@ -760,7 +760,7 @@ defmodule Enum do
760
760
end
761
761
762
762
@ 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 .
764
764
765
765
## Examples
766
766
@@ -784,7 +784,7 @@ defmodule Enum do
784
784
Returns a new collection appending the result of invoking `fun`
785
785
on each corresponding item of `collection`.
786
786
787
- Given function should return a list.
787
+ The given function should return a list.
788
788
789
789
## Examples
790
790
@@ -805,7 +805,7 @@ defmodule Enum do
805
805
end
806
806
807
807
@ doc """
808
- Intersperses the `element` between each element of the enumeration.
808
+ Intersperses `element` between each element of the enumeration.
809
809
810
810
Complexity: O(n)
811
811
@@ -865,7 +865,7 @@ defmodule Enum do
865
865
Returns a new collection, where each item is the result
866
866
of invoking `fun` on each corresponding item of `collection`.
867
867
868
- For dicts, the function accepts a key-value tuple.
868
+ For dicts, the function expects a key-value tuple.
869
869
870
870
## Examples
871
871
@@ -1227,7 +1227,7 @@ defmodule Enum do
1227
1227
1228
1228
@ doc """
1229
1229
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
1231
1231
for the next computation.
1232
1232
1233
1233
## Examples
@@ -1245,8 +1245,8 @@ defmodule Enum do
1245
1245
1246
1246
@ doc """
1247
1247
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.
1250
1250
1251
1251
## Examples
1252
1252
@@ -1264,7 +1264,7 @@ defmodule Enum do
1264
1264
@ doc """
1265
1265
Returns a list of collection elements shuffled.
1266
1266
1267
- Notice you need to explicitly call `:random.seed/1` and
1267
+ Notice that you need to explicitly call `:random.seed/1` and
1268
1268
set a seed value for the random algorithm. Otherwise, the
1269
1269
default seed will be set which will always return the same
1270
1270
result. For example, one could do the following to set a seed
@@ -1385,7 +1385,9 @@ defmodule Enum do
1385
1385
end
1386
1386
1387
1387
@ 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.
1389
1391
1390
1392
## Examples
1391
1393
@@ -1521,8 +1523,8 @@ defmodule Enum do
1521
1523
end
1522
1524
1523
1525
@ 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 .
1526
1528
1527
1529
## Examples
1528
1530
0 commit comments