Skip to content

Commit cda0c6c

Browse files
committed
Fixed typos in Enum docs
1 parent e6b075f commit cda0c6c

File tree

1 file changed

+53
-44
lines changed

1 file changed

+53
-44
lines changed

lib/elixir/lib/enum.ex

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defprotocol Enumerable do
1010
1111
Enum.map([1, 2, 3], &1 * 2)
1212
13-
`Enum.map` invokes `Enumerable.reduce` to perform the reducing operation
13+
`Enum.map/2` invokes `Enumerable.reduce/3` to perform the reducing operation
1414
that builds a mapped list by calling the mapping function `&1 * 2` on every
1515
element in the collection and cons'ing the element with the accumulated list.
1616
"""
@@ -27,7 +27,7 @@ defprotocol Enumerable do
2727
def reduce([h|t], acc, fun), do: reduce(t, fun.(h, acc), fun)
2828
def reduce([], acc, _fun), do: acc
2929
30-
As an additional example, here is the implementation of `Enum.map` with
30+
As an additional example, here is the implementation of `Enum.map/2` with
3131
`Enumerable`:
3232
3333
def map(collection, fun) do
@@ -39,12 +39,12 @@ defprotocol Enumerable do
3939
def reduce(collection, acc, fun)
4040

4141
@doc """
42-
The function used to check if a value exists within the collection.
42+
The function is used to check if a value exists within the collection.
4343
"""
4444
def member?(collection, value)
4545

4646
@doc """
47-
The function used to retrieve the collection's size.
47+
The function is used to retrieve the collection's size.
4848
"""
4949
def count(collection)
5050
end
@@ -56,7 +56,7 @@ defmodule Enum do
5656
Provides a set of algorithms that enumerate over collections according to the
5757
`Enumerable` protocol. Most of the functions in this module have two
5858
flavours. If a given collection implements the mentioned protocol (like
59-
list, for instance), you can do:
59+
`List`, for instance), you can do:
6060
6161
Enum.map([1, 2, 3], fn(x) -> x * 2 end)
6262
@@ -73,7 +73,7 @@ defmodule Enum do
7373
@type default :: any
7474

7575
@doc """
76-
Checks if the `value` exists within the `collection`.
76+
Checks if `value` exists within the `collection`.
7777
7878
## Examples
7979
@@ -89,7 +89,7 @@ defmodule Enum do
8989
end
9090

9191
@doc """
92-
Returns the collection size.
92+
Returns the collection's size.
9393
9494
## Examples
9595
@@ -103,7 +103,8 @@ defmodule Enum do
103103
end
104104

105105
@doc """
106-
Counts for how many items the function returns true.
106+
Returns the count of items in the collection for which
107+
`fun` returns `true`.
107108
108109
## Examples
109110
iex> Enum.count([1, 2, 3, 4, 5], fn(x) -> rem(x, 2) == 0 end)
@@ -118,8 +119,8 @@ defmodule Enum do
118119
end
119120

120121
@doc """
121-
Invokes the given `fun` for each item in the `collection` and returns false
122-
if at least one invocation returns false. Otherwise returns true.
122+
Invokes the given `fun` for each item in the `collection` and returns `false`
123+
if at least one invocation returns `false`. Otherwise returns `true`.
123124
124125
## Examples
125126
@@ -130,7 +131,7 @@ defmodule Enum do
130131
false
131132
132133
If no function is given, it defaults to checking if
133-
all items in the collection evaluate to true.
134+
all items in the collection evaluate to `true`.
134135
135136
iex> Enum.all?([1, 2, 3])
136137
true
@@ -156,8 +157,8 @@ defmodule Enum do
156157
end
157158

158159
@doc """
159-
Invokes the given `fun` for each item in the `collection` and returns true if
160-
at least one invocation returns true. Returns false otherwise.
160+
Invokes the given `fun` for each item in the `collection` and returns `true` if
161+
at least one invocation returns `true`. Returns `false` otherwise.
161162
162163
## Examples
163164
@@ -168,7 +169,7 @@ defmodule Enum do
168169
true
169170
170171
If no function is given, it defaults to checking if
171-
at least one item in the collection evaluates to true.
172+
at least one item in the collection evaluates to `true`.
172173
173174
iex> Enum.any?([false, false, false])
174175
false
@@ -222,7 +223,7 @@ defmodule Enum do
222223
end
223224

224225
@doc """
225-
Drops the first `count` items from the collection.
226+
Drops the first `count` items from `collection`.
226227
Expects an ordered collection.
227228
228229
## Examples
@@ -254,7 +255,7 @@ defmodule Enum do
254255
end
255256

256257
@doc """
257-
Drops items at the beginning of `collection` while `fun` returns true.
258+
Drops items at the beginning of `collection` while `fun` returns `true`.
258259
Expects an ordered collection.
259260
260261
## Examples
@@ -301,7 +302,7 @@ defmodule Enum do
301302
end
302303

303304
@doc """
304-
Returns true if the collection is empty, otherwise false.
305+
Returns `true` if the collection is empty, otherwise `false`.
305306
306307
## Examples
307308
@@ -384,7 +385,7 @@ defmodule Enum do
384385

385386
@doc """
386387
Filters the collection, i.e. returns only those elements
387-
for which `fun` returns true.
388+
for which `fun` returns `true`.
388389
389390
## Examples
390391
@@ -457,7 +458,7 @@ defmodule Enum do
457458
end
458459

459460
@doc """
460-
Similar to find, but returns the value of the function
461+
Similar to `find/3`, but returns the value of the function
461462
invocation instead of the element itself.
462463
463464
## Examples
@@ -488,8 +489,8 @@ defmodule Enum do
488489
end
489490

490491
@doc """
491-
Similar to find, but returns the index (count starts with 0)
492-
of the item instead of the element itself.
492+
Similar to `find/3`, but returns the index (zero-based)
493+
of the element instead of the element itself.
493494
494495
Expects an ordered collection.
495496
@@ -517,7 +518,7 @@ defmodule Enum do
517518
end
518519

519520
@doc """
520-
Returns the first item in the collection or nil otherwise.
521+
Returns the first item in the collection or `nil` otherwise.
521522
522523
## Examples
523524
@@ -541,13 +542,13 @@ defmodule Enum do
541542

542543
@doc """
543544
Joins the given `collection` according to `joiner`.
544-
Joiner can be either a binary or a list and the
545-
result will be of the same type as joiner. If
546-
joiner is not passed at all, it defaults to an
545+
`joiner` can be either a binary or a list and the
546+
result will be of the same type as `joiner`. If
547+
`joiner` is not passed at all, it defaults to an
547548
empty binary.
548549
549550
All items in the collection must be convertible
550-
to binary, otherwise an error is raised.
551+
to a binary, otherwise an error is raised.
551552
552553
## Examples
553554
@@ -602,13 +603,13 @@ defmodule Enum do
602603

603604
@doc """
604605
Maps and joins the given `collection` in one pass.
605-
Joiner can be either a binary or a list and the
606-
result will be of the same type as joiner. If
607-
joiner is not passed at all, it defaults to an
606+
`joiner` can be either a binary or a list and the
607+
result will be of the same type as `joiner`. If
608+
`joiner` is not passed at all, it defaults to an
608609
empty binary.
609610
610611
All items in the collection must be convertible
611-
to binary, otherwise an error is raised.
612+
to a binary, otherwise an error is raised.
612613
613614
## Examples
614615
@@ -648,8 +649,8 @@ defmodule Enum do
648649
the first element is the mapped collection and the second
649650
one is the final accumulator.
650651
651-
For dicts, the first tuple element has to be a { key, value }
652-
tuple itself.
652+
For dicts, the first tuple element must be a `{ key, value }`
653+
tuple.
653654
654655
## Examples
655656
@@ -667,9 +668,9 @@ defmodule Enum do
667668
end
668669

669670
@doc """
670-
Partitions `collection` into two where the first one contains elements
671+
Partitions `collection` into two collections, where the first one contains elements
671672
for which `fun` returns a truthy value, and the second one -- for which `fun`
672-
returns false or nil.
673+
returns `false` or `nil`.
673674
674675
## Examples
675676
@@ -707,7 +708,7 @@ defmodule Enum do
707708
end
708709

709710
@doc """
710-
Returns elements of collection for which `fun` returns false.
711+
Returns elements of collection for which `fun` returns `false`.
711712
712713
## Examples
713714
@@ -748,6 +749,14 @@ defmodule Enum do
748749

749750
@doc """
750751
Returns a list of collection elements shuffled.
752+
753+
## Examples
754+
755+
iex(1)> Enum.shuffle([1, 2, 3])
756+
[3, 2, 1]
757+
iex(2)> Enum.shuffle([1, 2, 3])
758+
[3, 1, 2]
759+
751760
"""
752761
@spec shuffle(t) :: list
753762
def shuffle(collection) do
@@ -803,8 +812,8 @@ defmodule Enum do
803812
collection.
804813
805814
Be aware that a negative `count` implies the collection
806-
will be iterate twice. One to calculate the position and
807-
another one to do the actual splitting.
815+
will be iterated twice. Once to calculate the position and
816+
a second time to do the actual splitting.
808817
809818
## Examples
810819
@@ -844,7 +853,7 @@ defmodule Enum do
844853
end
845854

846855
@doc """
847-
Splits `collection` in two while `fun` returns true.
856+
Splits `collection` in two while `fun` returns `true`.
848857
849858
## Examples
850859
@@ -910,7 +919,7 @@ defmodule Enum do
910919
end
911920

912921
@doc """
913-
Takes the items at the beginning of `collection` while `fun` returns true.
922+
Takes the items at the beginning of `collection` while `fun` returns `true`.
914923
Expects an ordered collection.
915924
916925
## Examples
@@ -993,7 +1002,7 @@ defmodule Enum do
9931002
Zips corresponding elements from two collections into one list
9941003
of tuples. The number of elements in the resulting list is
9951004
dictated by the first enum. In case the second list is shorter,
996-
values are filled with nil.
1005+
values are filled with `nil`.
9971006
9981007
## Examples
9991008
@@ -1024,7 +1033,7 @@ defmodule Enum do
10241033

10251034
@doc """
10261035
Returns the maximum value.
1027-
Raises empty error in case the collection is empty.
1036+
Raises `EmptyError` if the collection is empty.
10281037
10291038
## Examples
10301039
@@ -1059,7 +1068,7 @@ defmodule Enum do
10591068

10601069
@doc """
10611070
Returns the maximum value.
1062-
Raises empty error in case the collection is empty.
1071+
Raises `EmptyError` if the collection is empty.
10631072
10641073
## Examples
10651074
@@ -1098,7 +1107,7 @@ defmodule Enum do
10981107

10991108
@doc """
11001109
Returns the minimum value.
1101-
Raises empty error in case the collection is empty.
1110+
Raises `EmptyError` if the collection is empty.
11021111
11031112
## Examples
11041113
@@ -1138,7 +1147,7 @@ defmodule Enum do
11381147

11391148
@doc """
11401149
Returns the minimum value.
1141-
Raises empty error in case the collection is empty.
1150+
Raises `EmptyError` if the collection is empty.
11421151
11431152
## Examples
11441153

0 commit comments

Comments
 (0)