Documentation

Common.List.NonEmpty

Common.List.NonEmpty #

A List with at least one member.

structure List.NonEmpty (α : Type u_1) :
Type u_1
  • head : α
  • tail : List α
Instances For
    instance List.instCoeNonEmptyList {α : Type u_1} :
    Equations
    • List.instCoeNonEmptyList = { coe := fun (xs : List.NonEmpty α) => xs.head :: xs.tail }
    instance List.instCoeDepListConsNonEmpty {α : Type u_1} {x : α} {xs : List α} :
    CoeDep (List α) (x :: xs) (List.NonEmpty α)
    Equations
    • List.instCoeDepListConsNonEmpty = { coe := { head := x, tail := xs } }
    def List.NonEmpty.length {α : Type u_1} (xs : List.NonEmpty α) :

    The length of a List.NonEmpty.

    Equations
    Instances For

      The length of a List.NonEmpty is always one plus the length of its tail.

      @[inline, reducible]
      abbrev List.NonEmpty.inBounds {α : Type u_1} (xs : List.NonEmpty α) (i : ) :

      A proof that an index is within the bounds of the List.NonEmpty.

      Equations
      Instances For
        def List.NonEmpty.get {α : Type u_1} (xs : List.NonEmpty α) (i : ) (h : List.NonEmpty.inBounds xs i) :
        α

        Retrieves the member of the List.NonEmpty at the specified index.

        Equations
        Instances For
          def List.NonEmpty.get? {α : Type u_1} :
          List.NonEmpty αOption α

          Variant of get that returns an Option α in the case of an invalid index.

          Equations
          Instances For
            instance List.NonEmpty.instGetElemNonEmptyNatInBounds {α : Type u_1} :
            GetElem (List.NonEmpty α) α List.NonEmpty.inBounds

            Type class instance for allowing direct indexing notation.

            Equations
            • List.NonEmpty.instGetElemNonEmptyNatInBounds = { getElem := List.NonEmpty.get }
            def List.NonEmpty.toList {α : Type u_1} (xs : List.NonEmpty α) :
            List α

            Convert a List.NonEmpty into a plain List.

            Equations
            Instances For
              def List.NonEmpty.last {α : Type u_1} :
              List.NonEmpty αα

              Retrieve the last member of the List.NonEmpty.

              Equations
              Instances For