Documentation

Std.Data.Array.Init.Basic

Bootstrapping definitions about arrays #

This file contains some definitions in Array needed for Std.List.Basic.

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

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

Equations
Instances For
    @[inline]
    def Array.toListAppend {α : Type u_1} (as : Array α) (l : List α) :
    List α

    Like as.toList ++ l, but in a single pass.

    Equations
    Instances For
      def Array.ofFn {α : Type u_1} {n : Nat} (f : Fin nα) :

      ofFn f with f : Fin n → α returns the list whose ith element is f i.

      ofFn f = #[f 0, f 1, ... , f(n - 1)]
      
      Equations
      Instances For
        def Array.ofFn.go {α : Type u_1} {n : Nat} (f : Fin nα) (i : Nat) (acc : Array α) :

        Auxiliary for ofFn. ofFn.go f i acc = acc ++ #[f i, ..., f(n - 1)]

        Equations
        Instances For

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

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

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

            Equations
            Instances For