Utils.List_utils
Helper functions for List
s
Cross product of two lists, l1 and l2, combining its elements with function f
If l1 is of size n and l2 of size m, the cross product is of size n * m
Uses Stdlib.compare
to produce a list with duplicate elements removed
The resulting list will also be sorted.
Gives the intersection of two lists
This uses the polymorphic =
Gives the cross-product of a 2D list
A 2D list of size x * y
will give a product of size x ^ y
The same as List.combine
, but allows the first list to be longer than the second
Similar to List.filter_map
, but returns None
if, for any element x
, f x = None
Returns a sublist using an offset and length
Returns None
if the list is too short
Gives the index of an element in a list
Uses polymorphic =
, and returns None
if not found
Returns Left v
if v
is the nth element of lst
or Right sz
if the list is too short and is of size sz
. Fails if provided a negative n
.
Returns the list without the first element that matches the predicate, and the removed element if it exists
Splits a list into head and tail
Returns (None, [])
if the list is empty
Similar to flaky_map
, but with Result
s, giving the first error if one exists