Documentation

Batteries.Data.Stream

def Stream.drop {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) :
Natσ

Drop up to n values from the stream s.

Equations
Instances For
    def Stream.take {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) :
    NatList α × σ

    Read up to n values from the stream s as a list from first to last.

    Equations
    Instances For
      @[simp]
      theorem Stream.fst_take_zero {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) :
      (Stream.take s 0).fst = []
      theorem Stream.fst_take_succ {σ : Type u_1} {α : Type u_2} {n : Nat} [Stream σ α] (s : σ) :
      (Stream.take s (n + 1)).fst = match Stream.next? s with | none => [] | some (a, s) => a :: (Stream.take s n).fst
      @[simp]
      theorem Stream.snd_take_eq_drop {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (n : Nat) :
      (Stream.take s n).snd = Stream.drop s n
      def Stream.takeTR {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (n : Nat) :
      List α × σ

      Tail recursive version of Stream.take.

      Equations
      Instances For
        def Stream.takeTR.loop {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (acc : List α) :
        NatList α × σ

        Inner loop for Stream.takeTR.

        Equations
        Instances For
          theorem Stream.fst_takeTR_loop {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (acc : List α) (n : Nat) :
          (Stream.takeTR.loop s acc n).fst = acc.reverseAux (Stream.take s n).fst
          theorem Stream.fst_takeTR {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (n : Nat) :
          (Stream.takeTR s n).fst = (Stream.take s n).fst
          theorem Stream.snd_takeTR_loop {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (acc : List α) (n : Nat) :
          (Stream.takeTR.loop s acc n).snd = Stream.drop s n
          theorem Stream.snd_takeTR {σ : Type u_1} {α : Type u_2} [Stream σ α] (s : σ) (n : Nat) :
          @[simp]
          theorem List.stream_drop_eq_drop {α : Type u_1} {n : Nat} (l : List α) :
          @[simp]
          theorem List.stream_take_eq_take_drop {α : Type u_1} {n : Nat} (l : List α) :