Module ListExtras


module ListExtras: sig  end
Utility functions for dealing with lists



Searching


val index : 'a -> 'a list -> int
index item list returns the 0-based position of index in list.
Raises Not_found if the item isn't in list.
val indexq : 'a -> 'a list -> int
Same as index but using physical equality instead of structural equality to compare the elements.


Complex equality



The following functor provides list functions that compare items of lists in terms of a user-defined equality function rather than the built-in = or == operators.

module type ComparableType = sig  end
Input signature of the functor ListExtras.Make.
module type S = sig  end
Output signature of the functor ListExtras.Make
module Make: functor (Comp : ComparableType) -> sig  end


Sorting


val munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b list -> 'b list
Implements munging/Schwartzian transform on a list. Maps 'a list to 'b list and returns the original 'a list ordered by a sort of 'b list.
val stable_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b list -> 'b list
The same using a stable sort
val fast_munge : cmp:('a -> 'a -> int) -> f:('b -> 'a) -> 'b list -> 'b list
The same using the fastest list sorting


Extracting elements



These are lifted from scheme.

val car : 'a list -> 'a
Same as List.hd
val cdr : 'a list -> 'a list
Same as List.tl
val cadr : 'a list -> 'a
val cddr : 'a list -> 'a list
val caddr : 'a list -> 'a
val cdddr : 'a list -> 'a list
val cadddr : 'a list -> 'a
val cddddr : 'a list -> 'a list
val tail : 'a list -> int -> 'a list
Returns the nth cdr (Zero-based) of list