Documentation

Std.Data.Array.Basic

Definitions on Arrays #

This file contains various definitions on Array. It does not contain proofs about these definitions, those are contained in other files in Std.Data.Array.

def Array.range (n : Nat) :

The array #[0, 1, ..., n - 1].

Instances For
def Array.reduceOption {α : Type u_1} (l : Array ()) :

Drop nones from a Array, and replace each remaining some a with a.

Instances For
def Array.flatten {α : Type u_1} (arr : Array ()) :

Turns #[#[a₁, a₂, ⋯], #[b₁, b₂, ⋯], ⋯] into #[a₁, a₂, ⋯, b₁, b₂, ⋯]

Instances For
def Array.zipWithIndex {α : Type u_1} (arr : ) :
Array (α × Nat)

Turns #[a, b] into #[(a, 0), (b, 1)].

Instances For
def Array.equalSet {α : Type u_1} [BEq α] (xs : ) (ys : ) :

Check whether xs and ys are equal as sets, i.e. they contain the same elements when disregarding order and duplicates. O(n*m)! If your element type has an Ord instance, it is asymptotically more efficient to sort the two arrays, remove duplicates and then compare them elementwise.

Instances For
def Array.qsortOrd {α : Type u_1} [ord : Ord α] (xs : ) :

Sort an array using compare to compare elements.

Instances For
@[inline]
def Array.minD {α : Type u_1} [ord : Ord α] (xs : ) (d : α) (start : ) (stop : ) :
α

Find the first minimal element of an array. If the array is empty, d is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
@[inline]
def Array.min? {α : Type u_1} [ord : Ord α] (xs : ) (start : ) (stop : ) :

Find the first minimal element of an array. If the array is empty, none is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
@[inline]
def Array.minI {α : Type u_1} [ord : Ord α] [] (xs : ) (start : ) (stop : ) :
α

Find the first minimal element of an array. If the array is empty, default is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
@[inline]
def Array.maxD {α : Type u_1} [ord : Ord α] (xs : ) (d : α) (start : ) (stop : ) :
α

Find the first maximal element of an array. If the array is empty, d is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
@[inline]
def Array.max? {α : Type u_1} [ord : Ord α] (xs : ) (start : ) (stop : ) :

Find the first maximal element of an array. If the array is empty, none is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
@[inline]
def Array.maxI {α : Type u_1} [ord : Ord α] [] (xs : ) (start : ) (stop : ) :
α

Find the first maximal element of an array. If the array is empty, default is returned. If start and stop are given, only the subarray xs[start:stop] is considered.

Instances For
def Subarray.empty {α : Type u_1} :

The empty subarray.

Instances For
@[inline]
def Subarray.isEmpty {α : Type u_1} (as : ) :

Check whether a subarray is empty.

Instances For
@[inline]
def Subarray.contains {α : Type u_1} [BEq α] (as : ) (a : α) :

Check whether a subarray contains an element.

Instances For
def Subarray.popHead? {α : Type u_1} (as : ) :
Option (α × )

Remove the first element of a subarray. Returns the element and the remaining subarray, or none if the subarray is empty.

Instances For