@@ -15,9 +15,9 @@ defprotocol Enumerable do
15
15
16
16
Internally, `Enum.map/2` is implemented as follows:
17
17
18
- def map(enum , fun) do
18
+ def map(enumerable , fun) do
19
19
reducer = fn x, acc -> {:cont, [fun.(x) | acc]} end
20
- Enumerable.reduce(enum , {:cont, []}, reducer) |> elem(1) |> :lists.reverse()
20
+ Enumerable.reduce(enumerable , {:cont, []}, reducer) |> elem(1) |> :lists.reverse()
21
21
end
22
22
23
23
Notice the user-supplied function is wrapped into a `t:reducer/0` function.
@@ -420,7 +420,7 @@ defmodule Enum do
420
420
end
421
421
422
422
@ doc """
423
- Chunks the `enum ` with fine grained control when every chunk is emitted.
423
+ Chunks the `enumerable ` with fine grained control when every chunk is emitted.
424
424
425
425
`chunk_fun` receives the current element and the accumulator and
426
426
must return `{:cont, element, acc}` to emit the given chunk and
@@ -456,9 +456,9 @@ defmodule Enum do
456
456
( acc -> { :cont , chunk , acc } | { :cont , acc } )
457
457
) :: Enumerable . t ( )
458
458
when chunk: any
459
- def chunk_while ( enum , acc , chunk_fun , after_fun ) do
459
+ def chunk_while ( enumerable , acc , chunk_fun , after_fun ) do
460
460
{ _ , { res , acc } } =
461
- Enumerable . reduce ( enum , { :cont , { [ ] , acc } } , fn entry , { buffer , acc } ->
461
+ Enumerable . reduce ( enumerable , { :cont , { [ ] , acc } } , fn entry , { buffer , acc } ->
462
462
case chunk_fun . ( entry , acc ) do
463
463
{ :cont , emit , acc } -> { :cont , { [ emit | buffer ] , acc } }
464
464
{ :cont , acc } -> { :cont , { buffer , acc } }
@@ -1024,9 +1024,9 @@ defmodule Enum do
1024
1024
1025
1025
## Examples
1026
1026
1027
- iex> enum = 1..100
1027
+ iex> enumerable = 1..100
1028
1028
iex> n = 3
1029
- iex> Enum.flat_map_reduce(enum , 0, fn i, acc ->
1029
+ iex> Enum.flat_map_reduce(enumerable , 0, fn i, acc ->
1030
1030
...> if acc < n, do: {[i], acc + 1}, else: {:halt, acc}
1031
1031
...> end)
1032
1032
{[1, 2, 3], 3}
0 commit comments