Skip to content

Commit d1e26ea

Browse files
committed
Move definition of with_index below
Right now is defined in the middle of two definitions of max function.
1 parent cca4ac9 commit d1e26ea

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/elixir/lib/enum.ex

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,23 +1058,6 @@ defmodule Enum do
10581058
end
10591059
end
10601060

1061-
@doc """
1062-
Returns the collection with each element wrapped in a tuple
1063-
along side its index.
1064-
1065-
## Examples
1066-
1067-
iex> Enum.with_index [1,2,3]
1068-
[{1,0},{2,1},{3,2}]
1069-
1070-
"""
1071-
@spec with_index(t) :: list({ element, non_neg_integer })
1072-
def with_index(collection) do
1073-
map_reduce(collection, 0, fn x, acc ->
1074-
{ { x, acc }, acc + 1 }
1075-
end) |> elem(0)
1076-
end
1077-
10781061
@doc """
10791062
Returns the maximum value.
10801063
Raises empty error in case the collection is empty.
@@ -1193,6 +1176,23 @@ defmodule Enum do
11931176
end
11941177
end
11951178

1179+
@doc """
1180+
Returns the collection with each element wrapped in a tuple
1181+
along side its index.
1182+
1183+
## Examples
1184+
1185+
iex> Enum.with_index [1,2,3]
1186+
[{1,0},{2,1},{3,2}]
1187+
1188+
"""
1189+
@spec with_index(t) :: list({ element, non_neg_integer })
1190+
def with_index(collection) do
1191+
map_reduce(collection, 0, fn x, acc ->
1192+
{ { x, acc }, acc + 1 }
1193+
end) |> elem(0)
1194+
end
1195+
11961196
## Helpers
11971197

11981198
defp iterate_and_count(collection, count) do

0 commit comments

Comments
 (0)