package links
Lists
fromTo a b
is the list of consecutive integers starting with a
and ending with b-1
. Throws Invalid_argument "fromTo"
if b < a
.
all_equiv rel list
: given an equiv. rel'n rel
, determine whether all elements of list
are equivalent.
span pred list
: partition list
into an initial sublist satisfying pred
and the remainder.
groupBy rel list
: given a binary rel'n rel
, partition list
into chunks s.t. successive elements x
, y
in a chunk give the same value under rel
.
groupByPred pred
partitions list
into chunks where all elements in the chunk give the same value under pred
.
groupByPred'
: Alternate implementation of groupByPred.
unsnoc list
: Partition list
into its last element and all the others.
unsnoc_opt list
: Partition list
into its last element and all the others.
last_opt list
: Return the last element of a list, or None if the list is empty.
curtail list
: Return a copy of the list with the last element removed.
Convert a (bivalent) less-than function into a (three-valued) comparison function.
Remove duplicates from a list, using the given relation to determine `duplicates'
Collects only elements which are duplicate in the original list.
Filter on two lists and map them together. Equivalent to map -<- filter -<- zip precondition: the two lists must be the same length