Skip to content

Commit 2f49952

Browse files
committed
Clean up docs
1 parent b9474da commit 2f49952

File tree

1 file changed

+27
-99
lines changed

1 file changed

+27
-99
lines changed

lib/elixir/lib/enum.ex

Lines changed: 27 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,18 +3463,19 @@ defmodule Enum do
34633463
34643464
## Zipping Maps
34653465
3466-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3467-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3468-
think that you will get the given key in the left map and the matching key in the right map, but
3469-
there is no such guarantee because map keys are not ordered! Consider the following:
3466+
It's important to remember that zipping inherently relies on order.
3467+
If you zip two lists you get the element at the index from each list in turn.
3468+
If we zip two maps together it's tempting to think that you will get the given
3469+
key in the left map and the matching key in the right map, but there is no such
3470+
guarantee because map keys are not ordered! Consider the following:
34703471
34713472
left = %{:a => 1, 1 => 3}
34723473
right = %{:a => 1, :b => :c}
34733474
Enum.zip(left, right)
34743475
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
34753476
3476-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3477-
`Map.merge/3`
3477+
As you can see `:a` does not get paired with `:a`. If this is what you want,
3478+
you should use `Map.merge/3`.
34783479
34793480
## Examples
34803481
@@ -3503,31 +3504,17 @@ defmodule Enum do
35033504
end
35043505

35053506
@doc """
3506-
Zips corresponding elements from a finite collection of enumerables into list, transforming them with
3507-
the `zip_fun` function as it goes.
3507+
Zips corresponding elements from a finite collection of enumerables
3508+
into list, transforming them with the `zip_fun` function as it goes.
35083509
3509-
The first element from each of the enums in `enumerables` will be put into a list which is then
3510-
passed to the 1-arity `zip_fun` function. Then, the second elements from each of the enums are
3511-
put into a list and passed to `zip_fun`, and so on until any one of the enums in `enumerables`
3512-
runs out of elements.
3510+
The first element from each of the enums in `enumerables` will be put
3511+
into a list which is then passed to the 1-arity `zip_fun` function.
3512+
Then, the second elements from each of the enums are put into a list
3513+
and passed to `zip_fun`, and so on until any one of the enums in
3514+
`enumerables` runs out of elements.
35133515
35143516
Returns a list with all the results of calling `zip_fun`.
35153517
3516-
## Zipping Maps
3517-
3518-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3519-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3520-
think that you will get the given key in the left map and the matching key in the right map, but
3521-
there is no such guarantee because map keys are not ordered! Consider the following:
3522-
3523-
left = %{:a => 1, 1 => 3}
3524-
right = %{:a => 1, :b => :c}
3525-
Enum.zip(left, right)
3526-
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3527-
3528-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3529-
`Map.merge/3`
3530-
35313518
## Examples
35323519
35333520
iex> Enum.zip_with([[1, 2], [3, 4], [5, 6]], fn [x, y, z] -> x + y + z end)
@@ -3549,29 +3536,14 @@ defmodule Enum do
35493536
end
35503537

35513538
@doc """
3552-
Reduces a over two enumerables halting as soon as either enumerable is empty.
3553-
3554-
## Zipping Maps
3555-
3556-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3557-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3558-
think that you will get the given key in the left map and the matching key in the right map, but
3559-
there is no such guarantee because map keys are not ordered! Consider the following:
3560-
3561-
left = %{:a => 1, 1 => 3}
3562-
right = %{:a => 1, :b => :c}
3563-
Enum.zip(left, right)
3564-
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3565-
3566-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3567-
`Map.merge/3`
3539+
Reduces over two enumerables halting as soon as either enumerable is empty.
35683540
35693541
## Examples
35703542
35713543
iex> Enum.zip_reduce([1, 2], [3, 4], 0, fn x, y, acc -> x + y + acc end)
35723544
10
35733545
3574-
iex> Enum.zip_reduce([1, 2], [3, 4], [], fn x, y, acc -> [x + y |acc] end)
3546+
iex> Enum.zip_reduce([1, 2], [3, 4], [], fn x, y, acc -> [x + y | acc] end)
35753547
[6, 4]
35763548
"""
35773549
@doc since: "1.12.0"
@@ -3593,21 +3565,6 @@ defmodule Enum do
35933565
The reducer will receive 2 args, a list of elements (one from each enum) and the
35943566
accumulator.
35953567
3596-
## Zipping Maps
3597-
3598-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3599-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3600-
think that you will get the given key in the left map and the matching key in the right map, but
3601-
there is no such guarantee because map keys are not ordered! Consider the following:
3602-
3603-
left = %{:a => 1, 1 => 3}
3604-
right = %{:a => 1, :b => :c}
3605-
Enum.zip(left, right)
3606-
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3607-
3608-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3609-
`Map.merge/3`
3610-
36113568
## Examples
36123569
36133570
iex> enums = [[1, 1], [2, 2], [3, 3]]
@@ -3632,29 +3589,15 @@ defmodule Enum do
36323589
end
36333590

36343591
@doc """
3635-
Reduces over two enumerables halting if the accumulator returns `{:halt, value}` or if
3636-
either of the enumerables is empty.
3592+
Reduces over two enumerables halting if the accumulator returns
3593+
`{:halt, value}` or if either of the enumerables is empty.
36373594
3638-
The reducer will receive 3 args, the left enumerable's element, the right enumberable's
3639-
element and the accumulator. It should return one of:
3595+
The reducer will receive 3 args, the left enumerable's element,
3596+
the right enumberable's element and the accumulator. It should
3597+
return one of:
36403598
36413599
* `{:halt, value}` - This will halt the reduction and return `value`
3642-
* `{:cont, value}` - This will continue with the next step of the reduction.
3643-
3644-
## Zipping Maps
3645-
3646-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3647-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3648-
think that you will get the given key in the left map and the matching key in the right map, but
3649-
there is no such guarantee because map keys are not ordered! Consider the following:
3650-
3651-
left = %{:a => 1, 1 => 3}
3652-
right = %{:a => 1, :b => :c}
3653-
Enum.zip(left, right)
3654-
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3655-
3656-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3657-
`Map.merge/3`
3600+
* `{:cont, value}` - This will continue with the next step of the reduction
36583601
36593602
## Examples
36603603
@@ -3683,29 +3626,14 @@ defmodule Enum do
36833626
end
36843627

36853628
@doc """
3686-
Reduces over all enumerables halting if the accumulator returns `{:halt, value}` or if
3687-
any of the enumerables is empty.
3629+
Reduces over all enumerables halting if the accumulator returns
3630+
`{:halt, value}` or if any of the enumerables is empty.
36883631
3689-
The reducer will receive 2 args, a list of the yielded elements and the accumulator.
3690-
It should return one of:
3632+
The reducer will receive 2 args, a list of the yielded elements
3633+
and the accumulator. It should return one of:
36913634
36923635
* `{:halt, value}` - This will halt the reduction and return `value`
3693-
* `{:cont, value}` - This will continue with the next step of the reduction.
3694-
3695-
## Zipping Maps
3696-
3697-
It's important to remember that zipping inherently relies on order. If you zip two lists you get
3698-
the element at the index from each list in turn. If we zip two maps together it's tempting to
3699-
think that you will get the given key in the left map and the matching key in the right map, but
3700-
there is no such guarantee because map keys are not ordered! Consider the following:
3701-
3702-
left = %{:a => 1, 1 => 3}
3703-
right = %{:a => 1, :b => :c}
3704-
Enum.zip(left, right)
3705-
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3706-
3707-
As you can see `:a` does not get paired with `:a`. If this is what you want, you should use
3708-
`Map.merge/3`
3636+
* `{:cont, value}` - This will continue with the next step of the reduction
37093637
37103638
## Examples
37113639

0 commit comments

Comments
 (0)