Grouping consecutive list elements into pairs #
This file provides the elementary list operation that groups consecutive elements into disjoint ordered pairs, dropping a possible final unpaired element.
Main results #
List.pairAdjacentgroups consecutive elements into pairs.List.prod_map_pairAdjacentrecovers a mapped product from the pairs of an even-length list.List.length_pairAdjacentcomputes the number of pairs.
Group consecutive elements into disjoint ordered pairs, dropping a final unpaired element.
Equations
- (a :: b :: l).pairAdjacent = (a, b) :: l.pairAdjacent
- x✝.pairAdjacent = []
Instances For
Multiplying the mapped entries of each consecutive pair recovers the mapped product of an even-length list.
@[simp]
The number of consecutive pairs in a list is half its length, rounded down.