Enumerating list occurrences #
List.Enumeration xs f identifies the positions of xs with an index type, with f giving
the value at each index. Values need not be distinct: mapping a list retains every occurrence.
Main definitions #
List.Enumeration: an equivalence of positions together with its lookup law.List.Enumeration.ofNodup,List.Enumeration.range,List.Enumeration.singleton: the enumerations of a complete duplicate-free list, ofList.range n, and of a singleton.List.Enumeration.map,List.Enumeration.prod,List.Enumeration.append: compositional ordered enumerations.List.productIndexEquiv: the positions of a list product as pairs of positions, with the right coordinate varying fastest.List.appendIndexEquiv: the positions ofleft ++ rightas the positions ofleftfollowed by those ofright.List.Enumeration.reindex: rename indices without changing the list.
Main results #
List.Enumeration.get_eq: lookup at a position equals evaluation at its corresponding index.List.appendIndexEquiv_lt_iff: positions ofleftprecede positions ofright.
An ordered enumeration of occurrences, allowing different indices to have the same value.
The index assigned to each list position.
The value at a position is given by its assigned index.
A complete duplicate-free list enumerates the type of its values.
The numerical range enumerates its bounded indices in order.
A singleton has one occurrence, indexed by Unit.
Rename the occurrence indices without changing the list.
Mapping changes values but retains each occurrence and its index.
Products enumerate the right list for each successive occurrence of the left list.
Appending keeps every left occurrence before every right occurrence.