sublists #
List.Sublists gives a list of all (not necessarily contiguous) sublists of a list.
This file contains basic results on this function.
sublists #
Auxiliary helper definition for sublists'
Equations
- List.sublists'Aux a r₁ r₂ = List.foldl (fun r l => r ++ [a :: l]) r₂ r₁
Instances For
Auxiliary helper function for sublists
Equations
- List.sublistsAux a r = List.foldl (fun r l => r ++ [l, a :: l]) [] r
Instances For
sublistsLen #
Auxiliary function to construct the list of all sublists of a given length. Given an
integer n, a list l, a function f and an auxiliary list L, it returns the list made of
f applied to all sublists of l of length n, concatenated with L.
Equations
- List.sublistsLenAux 0 x x x = x [] :: x
- List.sublistsLenAux (Nat.succ n) [] x x = x
- List.sublistsLenAux (Nat.succ n) (a :: l) x x = List.sublistsLenAux (n + 1) l x (List.sublistsLenAux n l (x ∘ List.cons a) x)
Instances For
The list of all sublists of a list l that are of length n. For instance, for
l = [0, 1, 2, 3] and n = 2, one gets
[[2, 3], [1, 3], [1, 2], [0, 3], [0, 2], [0, 1]].
Equations
- List.sublistsLen n l = List.sublistsLenAux n l id []
Instances For
Alias of the forward direction of List.nodup_sublists.
Alias of the reverse direction of List.nodup_sublists.
Alias of the reverse direction of List.nodup_sublists'.
Alias of the forward direction of List.nodup_sublists'.