@@ -3463,18 +3463,19 @@ defmodule Enum do
3463
3463
3464
3464
## Zipping Maps
3465
3465
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:
3470
3471
3471
3472
left = %{:a => 1, 1 => 3}
3472
3473
right = %{:a => 1, :b => :c}
3473
3474
Enum.zip(left, right)
3474
3475
# [{{1, 3}, {:a, 1}}, {{:a, 1}, {:b, :c}}]
3475
3476
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`.
3478
3479
3479
3480
## Examples
3480
3481
@@ -3503,31 +3504,17 @@ defmodule Enum do
3503
3504
end
3504
3505
3505
3506
@ 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.
3508
3509
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.
3513
3515
3514
3516
Returns a list with all the results of calling `zip_fun`.
3515
3517
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
-
3531
3518
## Examples
3532
3519
3533
3520
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
3549
3536
end
3550
3537
3551
3538
@ 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.
3568
3540
3569
3541
## Examples
3570
3542
3571
3543
iex> Enum.zip_reduce([1, 2], [3, 4], 0, fn x, y, acc -> x + y + acc end)
3572
3544
10
3573
3545
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)
3575
3547
[6, 4]
3576
3548
"""
3577
3549
@ doc since: "1.12.0"
@@ -3593,21 +3565,6 @@ defmodule Enum do
3593
3565
The reducer will receive 2 args, a list of elements (one from each enum) and the
3594
3566
accumulator.
3595
3567
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
-
3611
3568
## Examples
3612
3569
3613
3570
iex> enums = [[1, 1], [2, 2], [3, 3]]
@@ -3632,29 +3589,15 @@ defmodule Enum do
3632
3589
end
3633
3590
3634
3591
@ 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.
3637
3594
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:
3640
3598
3641
3599
* `{: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
3658
3601
3659
3602
## Examples
3660
3603
@@ -3683,29 +3626,14 @@ defmodule Enum do
3683
3626
end
3684
3627
3685
3628
@ 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.
3688
3631
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:
3691
3634
3692
3635
* `{: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
3709
3637
3710
3638
## Examples
3711
3639
0 commit comments