# Documentation

Std.Data.Array.Merge

def Array.mergeSortedPreservingDuplicates {α : Type u_1} [ord : Ord α] (xs : ) (ys : ) :

Merge arrays xs and ys, which must be sorted according to compare. The result is sorted as well. If two (or more) elements are equal according to compare, they are preserved.

Equations
def Array.mergeSortedPreservingDuplicates.go {α : Type u_1} [ord : Ord α] (xs : ) (ys : ) (acc : ) (i : Nat) (j : Nat) :

Auxiliary definition for mergeSortedPreservingDuplicates.

Equations
• One or more equations did not get rendered due to their size.
def Array.mergeSortedMergingDuplicates {α : Type u_1} [ord : Ord α] (xs : ) (ys : ) (merge : ααα) :

Merge arrays xs and ys, which must be sorted according to compare and must not contain duplicates. Equal elements are merged using merge. If merge respects the order (i.e. for all x, y, y', z, if x < y < z and x < y' < z then x < merge y y' < z) then the resulting array is again sorted.

Equations
def Array.mergeSortedMergingDuplicates.go {α : Type u_1} [ord : Ord α] (xs : ) (ys : ) (merge : ααα) (acc : ) (i : Nat) (j : Nat) :

Auxiliary definition for mergeSortedMergingDuplicates.

Equations
• One or more equations did not get rendered due to their size.
@[inline]
def Array.mergeSortedDeduplicating {α : Type u_1} [ord : Ord α] (xs : ) (ys : ) :

Merge arrays xs and ys, which must be sorted according to compare and must not contain duplicates. If an element appears in both xs and ys, only one copy is kept.

Equations
def Array.mergeUnsortedDeduplicating {α : Type u_1} [eq : BEq α] (xs : ) (ys : ) :

Merge xs and ys, which do not need to be sorted. Elements which occur in both xs and ys are only added once. If xs and ys do not contain duplicates, then neither does the result. O(n*m)!

Equations
• = if < then else
@[inline]
def Array.mergeUnsortedDeduplicating.go {α : Type u_1} [eq : BEq α] (xs : ) (ys : ) :

Auxiliary definition for mergeUnsortedDeduplicating.

Equations
• One or more equations did not get rendered due to their size.
def Array.mergeAdjacentDuplicates {α : Type u_1} [eq : BEq α] (f : ααα) (xs : ) :

Replace each run [x₁, ⋯, xₙ]⋯, xₙ] of equal elements in xs with f ⋯ (f (f x₁ x₂) x₃) ⋯ xₙ⋯ (f (f x₁ x₂) x₃) ⋯ xₙ⋯ xₙ.

Equations
def Array.mergeAdjacentDuplicates.go {α : Type u_1} [eq : BEq α] (f : ααα) (xs : ) (acc : ) (i : Nat) (hd : α) :

Auxiliary definition for mergeAdjacentDuplicates.

Equations
• One or more equations did not get rendered due to their size.
def Array.deduplicateSorted {α : Type u_1} [eq : BEq α] (xs : ) :

Deduplicate a sorted array. The array must be sorted with to an order which agrees with ==, i.e. whenever x == y then compare x y == .eq.

Equations
def Array.sortAndDeduplicate {α : Type u_1} [ord : Ord α] (xs : ) :

Sort and deduplicate an array.

Equations