Module IStdlib.IList
val map_changed : equal:('a -> 'a -> bool) -> f:('a -> 'a) -> 'a list -> 'a list
like map, but returns the original list if unchanged
val filter_changed : f:('a -> bool) -> 'a list -> 'a list
like filter, but returns the original list if unchanged
val remove_irrelevant_duplicates : equal:('a -> 'a -> bool) -> f:('a -> bool) -> 'a list -> 'a list
Remove consecutive equal irrelevant elements from a list (according to the given comparison and relevance functions)
val merge_sorted_nodup : cmp:('a -> 'a -> int) -> res:'a list -> 'a list -> 'a list -> 'a list
The function works on sorted lists without duplicates, and keeps only one copy of elements that appear in both lists.
val inter : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
inter cmp xs ys
are the elements in bothxs
andys
, sorted according tocmp
.
val fold_last : 'a list -> init:'b -> f:('b -> 'a -> 'b) -> f_last:('b -> 'a -> 'b) -> 'b
like fold, but apply f_last to the last element
val split_last_rev : 'a list -> ('a * 'a list) option
split_last_rev l
isSome (last, rev_prefix)
wherelast :: (List.rev rev_prefix) == l
,None
ifl
is empty
val append_no_duplicates : cmp:('a -> 'a -> int) -> ('a list -> 'a list -> 'a list) IStdlib.IStd.Staged.t
append_no_duplicates list1 list2
, assuming that list1 and list2 have no duplicates on their own, it computeslist1 @ (filtered list2)
, so it keeps the order of both lists and has no duplicates.
val merge_dedup : 'a list -> 'a list -> compare:('a -> 'a -> int) -> 'a list
val drop : 'a list -> int -> 'a list
drop l n
returnsl
without the firstn
elements, or the empty list ifn > length l
.
val opt_cons : 'a option -> 'a list -> 'a list
opt_cons None l
returnsl
.opt_cons (Some x) l
returnsx :: l
val remove_first : 'a list -> f:('a -> bool) -> 'a list option
val force_until_first_some : 'a option lazy_t list -> 'a option
force_until_first_some xs
forces the computation of each element ofxs
and returns the first that matches (Some _); or, if no such element exists, it returns None.
val eval_until_first_some : (unit -> 'a option) list -> 'a option
given a list of functions taking unit, evaluate and return the first one to return
Some x
val pp_print_list : max:int -> ?pp_sep:(Stdlib.Format.formatter -> unit -> unit) -> (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a list -> unit
val fold2_result : init:'acc -> f:('acc -> 'a -> 'b -> ('acc, 'err) IStdlib.IStd.result) -> 'a list -> 'b list -> ('acc, 'err) IStdlib.IStd.result Base.List.Or_unequal_lengths.t
val move_last_to_first : 'a list -> 'a list
val traverse_opt : 'a list -> f:('a -> 'b option) -> 'b list option
Applies
f
to the elements of the list and returnsNone
if any application results inNone
otherwise returnsSome list'
.