@@ -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 )
5050end
@@ -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
@@ -221,7 +222,7 @@ defmodule Enum do
221222 end
222223
223224 @ doc """
224- Drops the first `count` items from the collection.
225+ Drops the first `count` items from ` collection` .
225226 Expects an ordered collection.
226227
227228 ## Examples
@@ -253,7 +254,7 @@ defmodule Enum do
253254 end
254255
255256 @ doc """
256- Drops items at the beginning of `collection` while `fun` returns true.
257+ Drops items at the beginning of `collection` while `fun` returns ` true` .
257258 Expects an ordered collection.
258259
259260 ## Examples
@@ -300,7 +301,7 @@ defmodule Enum do
300301 end
301302
302303 @ doc """
303- Returns true if the collection is empty, otherwise false.
304+ Returns ` true` if the collection is empty, otherwise ` false` .
304305
305306 ## Examples
306307
@@ -383,7 +384,7 @@ defmodule Enum do
383384
384385 @ doc """
385386 Filters the collection, i.e. returns only those elements
386- for which `fun` returns true.
387+ for which `fun` returns ` true` .
387388
388389 ## Examples
389390
@@ -456,7 +457,7 @@ defmodule Enum do
456457 end
457458
458459 @ doc """
459- Similar to find, but returns the value of the function
460+ Similar to ` find/3` , but returns the value of the function
460461 invocation instead of the element itself.
461462
462463 ## Examples
@@ -487,8 +488,8 @@ defmodule Enum do
487488 end
488489
489490 @ doc """
490- Similar to find, but returns the index (count starts with 0 )
491- of the item instead of the element itself.
491+ Similar to ` find/3` , but returns the index (zero-based )
492+ of the element instead of the element itself.
492493
493494 Expects an ordered collection.
494495
@@ -516,7 +517,7 @@ defmodule Enum do
516517 end
517518
518519 @ doc """
519- Returns the first item in the collection or nil otherwise.
520+ Returns the first item in the collection or ` nil` otherwise.
520521
521522 ## Examples
522523
@@ -540,13 +541,13 @@ defmodule Enum do
540541
541542 @ doc """
542543 Joins the given `collection` according to `joiner`.
543- Joiner can be either a binary or a list and the
544- result will be of the same type as joiner. If
545- joiner is not passed at all, it defaults to an
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
546547 empty binary.
547548
548549 All items in the collection must be convertible
549- to binary, otherwise an error is raised.
550+ to a binary, otherwise an error is raised.
550551
551552 ## Examples
552553
@@ -601,13 +602,13 @@ defmodule Enum do
601602
602603 @ doc """
603604 Maps and joins the given `collection` in one pass.
604- Joiner can be either a binary or a list and the
605- result will be of the same type as joiner. If
606- joiner is not passed at all, it defaults to an
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
607608 empty binary.
608609
609610 All items in the collection must be convertible
610- to binary, otherwise an error is raised.
611+ to a binary, otherwise an error is raised.
611612
612613 ## Examples
613614
@@ -647,8 +648,8 @@ defmodule Enum do
647648 the first element is the mapped collection and the second
648649 one is the final accumulator.
649650
650- For dicts, the first tuple element has to be a { key, value }
651- tuple itself .
651+ For dicts, the first tuple element must be a ` { key, value }`
652+ tuple.
652653
653654 ## Examples
654655
@@ -666,9 +667,9 @@ defmodule Enum do
666667 end
667668
668669 @ doc """
669- Partitions `collection` into two where the first one contains elements
670+ Partitions `collection` into two collections, where the first one contains elements
670671 for which `fun` returns a truthy value, and the second one -- for which `fun`
671- returns false or nil.
672+ returns ` false` or ` nil` .
672673
673674 ## Examples
674675
@@ -706,7 +707,7 @@ defmodule Enum do
706707 end
707708
708709 @ doc """
709- Returns elements of collection for which `fun` returns false.
710+ Returns elements of collection for which `fun` returns ` false` .
710711
711712 ## Examples
712713
@@ -747,6 +748,14 @@ defmodule Enum do
747748
748749 @ doc """
749750 Returns a list of collection elements shuffled.
751+
752+ ## Examples
753+
754+ iex(1)> Enum.shuffle([1, 2, 3])
755+ [3, 2, 1]
756+ iex(2)> Enum.shuffle([1, 2, 3])
757+ [3, 1, 2]
758+
750759 """
751760 @ spec shuffle ( t ) :: list
752761 def shuffle ( collection ) do
@@ -802,8 +811,8 @@ defmodule Enum do
802811 collection.
803812
804813 Be aware that a negative `count` implies the collection
805- will be iterate twice. One to calculate the position and
806- another one to do the actual splitting.
814+ will be iterated twice. Once to calculate the position and
815+ a second time to do the actual splitting.
807816
808817 ## Examples
809818
@@ -843,7 +852,7 @@ defmodule Enum do
843852 end
844853
845854 @ doc """
846- Splits `collection` in two while `fun` returns true.
855+ Splits `collection` in two while `fun` returns ` true` .
847856
848857 ## Examples
849858
@@ -909,7 +918,7 @@ defmodule Enum do
909918 end
910919
911920 @ doc """
912- Takes the items at the beginning of `collection` while `fun` returns true.
921+ Takes the items at the beginning of `collection` while `fun` returns ` true` .
913922 Expects an ordered collection.
914923
915924 ## Examples
@@ -992,7 +1001,7 @@ defmodule Enum do
9921001 Zips corresponding elements from two collections into one list
9931002 of tuples. The number of elements in the resulting list is
9941003 dictated by the first enum. In case the second list is shorter,
995- values are filled with nil.
1004+ values are filled with ` nil` .
9961005
9971006 ## Examples
9981007
@@ -1023,7 +1032,7 @@ defmodule Enum do
10231032
10241033 @ doc """
10251034 Returns the maximum value.
1026- Raises empty error in case the collection is empty.
1035+ Raises `EmptyError` if the collection is empty.
10271036
10281037 ## Examples
10291038
@@ -1058,7 +1067,7 @@ defmodule Enum do
10581067
10591068 @ doc """
10601069 Returns the maximum value.
1061- Raises empty error in case the collection is empty.
1070+ Raises `EmptyError` if the collection is empty.
10621071
10631072 ## Examples
10641073
@@ -1097,7 +1106,7 @@ defmodule Enum do
10971106
10981107 @ doc """
10991108 Returns the minimum value.
1100- Raises empty error in case the collection is empty.
1109+ Raises `EmptyError` if the collection is empty.
11011110
11021111 ## Examples
11031112
@@ -1137,7 +1146,7 @@ defmodule Enum do
11371146
11381147 @ doc """
11391148 Returns the minimum value.
1140- Raises empty error in case the collection is empty.
1149+ Raises `EmptyError` if the collection is empty.
11411150
11421151 ## Examples
11431152
0 commit comments