opam-core

Core library for opam 2.1
IN THIS PACKAGE
Module OpamStd . List
val cons : 'a -> 'a list -> 'a list
val concat_map : ?left:string -> ?right:string -> ?nil:string -> ?last_sep:string -> string -> ( 'a -> string ) -> 'a list -> string

Convert list items to string and concat. sconcat_map sep f x is equivalent to String.concat sep (List.map f x) but tail-rec.

val find_opt : ( 'a -> bool ) -> 'a list -> 'a option

Like List.find, but returning option instead of raising

val to_string : ( 'a -> string ) -> 'a list -> string
val remove_duplicates : 'a list -> 'a list

Removes consecutive duplicates in a list

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

Sorts the list, removing duplicates

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

Filter and map

val filter_some : 'a option list -> 'a list

Retrieves Some values from a list

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

Returns the first non-None value returned by the passed function on the elements of the passed list.

  • raises Not_found

    if all of them yield None

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

Insert a value in an ordered list

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

Inserts a value at the given index (starting from 0) in the list (start or end if index < 0 or > length respectively). Not tail-recursive

val assoc_opt : 'a -> ('a * 'b) list -> 'b option

Like List.find, but returning option instead of raising

val pick_assoc : 'a -> ('a * 'b) list -> 'b option * ('a * 'b) list

Like List.assoc, but as an option, and also returns the list with the binding removed, e.g. equivalent to (List.assoc_opt x l, List.remove_assoc x l) (but tail-recursive and more efficient)

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

update_assoc key value list updates the first value bound to key in the associative list list, or appends (key, value) if the key is not bound.