Documentation

Mathlib.Data.List.SplitLengths

Splitting a list to chunks of specified lengths #

This file defines splitting a list to chunks of given lengths, and some proofs about that.

def List.splitLengths {α : Type u_1} :
List List αList (List α)

Split a list to chunks of given lengths.

Equations
  • [].splitLengths x = []
  • (n :: ns).splitLengths x = match List.splitAt n x with | (x0, x1) => x0 :: ns.splitLengths x1
Instances For
    @[simp]
    theorem List.length_splitLengths {α : Type u_1} (l : List α) (sz : List ) :
    (sz.splitLengths l).length = sz.length
    @[simp]
    theorem List.splitLengths_nil {α : Type u_1} (l : List α) :
    [].splitLengths l = []
    @[simp]
    theorem List.splitLengths_cons {α : Type u_1} (l : List α) (sz : List ) (n : ) :
    (n :: sz).splitLengths l = List.take n l :: sz.splitLengths (List.drop n l)
    theorem List.take_splitLength {α : Type u_1} (l : List α) (sz : List ) (i : ) :
    List.take i (sz.splitLengths l) = (List.take i sz).splitLengths l
    theorem List.length_splitLengths_getElem_le {α : Type u_1} (l : List α) (sz : List ) {i : } {hi : i < (sz.splitLengths l).length} :
    (sz.splitLengths l)[i].length sz[i]
    theorem List.flatten_splitLengths {α : Type u_1} (l : List α) (sz : List ) (h : l.length sz.sum) :
    (sz.splitLengths l).flatten = l
    theorem List.map_splitLengths_length {α : Type u_1} (l : List α) (sz : List ) (h : sz.sum l.length) :
    List.map List.length (sz.splitLengths l) = sz
    theorem List.length_splitLengths_getElem_eq {α : Type u_1} (l : List α) (sz : List ) {i : } (hi : i < sz.length) (h : (List.take (i + 1) sz).sum l.length) :
    (sz.splitLengths l)[i].length = sz[i]
    theorem List.splitLengths_length_getElem {α : Type u_2} (l : List α) (sz : List ) (h : sz.sum l.length) (i : ) (hi : i < (sz.splitLengths l).length) :
    (sz.splitLengths l)[i].length = sz[i]
    theorem List.length_mem_splitLengths {α : Type u_2} (l : List α) (sz : List ) (b : ) (h : ∀ (n : ), n szn b) (l₂ : List α) :
    l₂ sz.splitLengths ll₂.length b