This module provides slice notation for list slices (a.k.a. Sublist) and implements an iterator
for those slices.
Internal representation of ListSlice, which is an abbreviation for Slice ListSliceData.
- list : List α
The relevant suffix of the underlying list.
The maximum length of the slice, starting at the beginning of
list.
Instances
A region of some underlying list. List slices can be used to avoid copying or allocating space, while being more convenient than tracking the bounds by hand.
A list slice only stores the suffix of the underlying list, starting from the range's lower bound so that the cost of operations on the slice does not depend on the start position. However, the cost of creating a list slice is linear in the start position.
Equations
Instances For
Returns a slice of a list with the given bounds.
If start or stop are not valid bounds for a sublist, then they are clamped to the list's length.
Additionally, the starting index is clamped to the ending index.
This function is linear in start because it stores as.drop start in the slice.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns a slice of a list with the given lower bound.
If start is not a valid bound for a sublist, then they are clamped to the list's length.
This function is linear in start because it stores as.drop start in the slice.
Equations
Instances For
Equations
- instSliceableListNatListSlice_2 = { mkSlice := fun (xs : List α) (range : Std.Rci Nat) => xs.toUnboundedSlice range.lower }
Equations
- instSliceableListNatListSlice_5 = { mkSlice := fun (xs : List α) (range : Std.Roi Nat) => xs.toUnboundedSlice (range.lower + 1) }
Equations
- instSliceableListNatListSlice_8 = { mkSlice := fun (xs : List α) (x : Std.Rii Nat) => xs.toUnboundedSlice 0 }