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.Enumeration.reindex: rename indices without changing the list.
Main results #
List.Enumeration.get_eq: lookup at a position equals evaluation at its corresponding index.
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.
Instances For
A complete duplicate-free list enumerates the type of its values.
Instances For
The numerical range enumerates its bounded indices in order.
Instances For
A singleton has one occurrence, indexed by Unit.
Instances For
Rename the occurrence indices without changing the list.
Instances For
Mapping changes values but retains each occurrence and its index.
Instances For
Products enumerate the right list for each successive occurrence of the left list.
Instances For
Appending keeps every left occurrence before every right occurrence.