Module UtilsLib.List

module List: sig .. end

Additional functions to the List module

val init : int -> (int -> 'a) -> 'a list

List.init n f returns a list of n elements that were created by calling the function f with parameter from 0 to n-1

val return : ('a -> 'b option) -> 'a list -> 'b

similar to List.find but returns the result of the function application

val return_opt : ('a -> 'b option) -> 'a list -> 'b option

same than List.return but exceptionless

val map_opt : ('a -> 'b option) -> 'a list -> 'b list

List.map and List.filter in one round

val assoc_err : 'a -> ('a * 'b) list -> err:string -> 'b

same than List.assoc but with a custom error message

val assoc_def : 'a -> ('a * 'b) list -> def:'b -> 'b

same than List.assoc but with a default value

val assoc_replace : 'a -> 'b -> ('a * 'b) list -> ('a * 'b) list

replace the associated value for the first key in an association list

val take : int -> 'a list -> 'a list

takes the n-th first elements of the list

val drop : int -> 'a list -> 'a list
val uniq : 'a list -> 'a list
val index : 'a -> 'a list -> int list
val starts_with : 'a list -> 'a list -> bool