package mopsa
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500
doc/containers/Containers/ListExt/index.html
Module Containers.ListExt
Source
ListExt - Adds a few useful functions to OCaml lists
Import everything from List
include module type of struct include Stdlib.List end
Operations
Tail-recursive version of map. Useful for large lists.
Tail-recursive version of append. Useful if the first list is large..
Maps e1;e2;...;en
to (f e1)@(f e2)@...@(f en)
Applies f to every element of the list and kepp only those that return some value. The order of the argument list is preserved.
split l
cuts the list l
into two halves. Either the two halves have the same size, or the first list is one element larger. If a,b = split l
, then l = a @ b
.
Printing
type list_printer = {
print_empty : string;
(*Special text for empty lists
*)print_begin : string;
(*Text before the first element.
*)print_sep : string;
(*Text between two elements
*)print_end : string;
(*Text after the last element
*)
}
Tells how to print a list.
Print as a space-sparated list, no delimiters.
Print as OCaml list: a;b;c
.
Print as OCaml tuple: (a,b,c).
Print as set: a;b;c
.
val print_gen :
('a -> string -> 'b) ->
list_printer ->
('a -> 'c -> unit) ->
'a ->
'c t ->
'b
val print :
list_printer ->
(Stdlib.out_channel -> 'a -> unit) ->
Stdlib.out_channel ->
'a t ->
unit
val bprint :
list_printer ->
(Stdlib.Buffer.t -> 'a -> unit) ->
Stdlib.Buffer.t ->
'a t ->
unit
val fprint :
list_printer ->
(Stdlib.Format.formatter -> 'a -> unit) ->
Stdlib.Format.formatter ->
'a t ->
unit
Parallel functions
As List.iter, but in parallel using nb_threads threads. As threads are used, this only makes sense if the iterated function calls a C function that temporarily lifts the global interpreter lock (e.g., the Clang parser)