package lutin

  1. Overview
  2. Docs

Miscellaneous general purposes functions.

val rm : 'a -> 'a list -> 'a0 list

rm x l returns l without x.

val rm_first : 'a -> 'a list -> 'a list

rm_first x l returns l without the left-most occurence of x.

val list_is_included : 'a list -> 'a list -> bool

list_is_included l1 l2 tests if elements of l1 are included into l2.

val count_empty_list : 'a list list -> int

count_empty_list llist counts the number of empty list that occurs in the list of list llist

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

compare 2 elements according to the order defined by a list

val string_to_string_list : string -> string list
val append_and_sort : 'a list -> 'a list -> 'b list

Appends two lists and sorts the result

val append_and_sort_rev : 'a list -> 'a list -> 'b list
val list_are_equals : 'a list -> 'a list -> bool

list_are_equals l1 l2 tests if l1 and l2 contains the same elements (in any order).

val list_intersec : 'a list -> 'a list -> 'a list

list_intersec l1 l2 returns all the elements that are both in l1 and l2.

val diff_list_as_set : 'a list -> 'a list -> 'a list

diff_list_as_set l1 l2 returns all the elements that are in l1 and not in l2.

val sorted : 'a list -> bool

Checks is a list is sorted w.r.t. compare

val power_2 : int -> int

power a b returns a to the power of b

val readfile_rm_crtl_m : string -> string
val list_iter3 : ('a -> 'b -> 'c -> unit) -> 'a list -> 'b list -> 'c list -> unit
val list_fold_left3 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'f -> 'g list -> 'h list -> 'i list -> 'j
val list_fold_left4 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'g -> 'h list -> 'i list -> 'j list -> 'k list -> 'l
val list_fold_left5 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) -> 'h -> 'i list -> 'j list -> 'k list -> 'l list -> 'm list -> 'n
val list_map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd0 list
val list_map4 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'a list -> 'b list -> 'c list -> 'd list -> 'e0 list
val list_map6 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) -> 'a list -> 'b list -> 'c list -> 'd list -> 'e list -> 'f list -> 'g0 list
val list_split3 : ('a * 'b * 'c) list -> 'a0 list * 'b0 list * 'c0 list
val list_split4 : ('a * 'b * 'c * 'd) list -> 'a0 list * 'b0 list * 'c0 list * 'd0 list
val list_split6 : ('a * 'b * 'c * 'd * 'e * 'f) list -> 'a0 list * 'b0 list * 'c0 list * 'd0 list * 'e0 list * 'f0 list
val list_split7 : ('a * 'b * 'c * 'd * 'e * 'f * 'g) list -> 'a0 list * 'b0 list * 'c0 list * 'd0 list * 'e0 list * 'f0 list * 'g0 list
val no_dup : 'a list -> 'a option

checks that a list does not contain any duplicate

val rm_dup : 'a list -> 'a list

Removes duplicates from a list (conserving its order)

val sort_list_string_pair : (string * 'a) list -> (string * 'a) list

Sorts a list of pair which lhs is a string lexicographically w.r.t. to this string.

val merge : 'a list -> 'a0 list -> 'a0 list

Merges two lists without introducing duplicates, respecting the original elements ordering.

val unfold : ('a -> 'b) -> 'a -> int -> 'b0 list

unfold f i n calls n times f i and returns the n results into a list, e.g., [(f i); (f i); ...; (f i)]. Of course, this makes more sense if f is not side effects free.

val unfold_do : ('a -> 'b) -> 'a0 -> int -> 'b list
val call_n_times : ('a -> 'a) -> 'a -> int -> 'a

call_n_times f i n applies f n times , e.g., f(f(f(f...(f i)))).

val hashtbl_size : ('a, 'b) Stdlib.Hashtbl.t -> int

Returns the size of an Hashtbl.

is_substring ss s test whether ss a sub-string of s

val is_substring : string -> string -> bool
val gauss_draw : float -> float -> float

gauss_draw m d generates a gaussian pseudo-random number of mean m and deviation d. The generation algorithm is based on the so-called << polar form of the Box-Muller transformation >> that I found it at the url http://www.taygeta.com/random/gaussian.html

val gauss_draw2 : float -> float -> float * float

Ditto, but returns 2 numbers. Indeed, the Box-Muller algorithm computes 2 of them anyway...

module StringMap : sig ... end

Map of strings

val mfind : StringMap.key -> 'a StringMap.t -> 'a
val hfind : ('a, 'b) Stdlib.Hashtbl.t -> 'a -> 'b
val precision : int Stdlib.ref
val eps : float Stdlib.ref
val update_eps : unit -> unit
val change_precision : int -> unit

I define my own version of print_float to turn around a bug (or is it a bug in ocaml?) of sim2chro where it does not understand floats without digit (e.g., 4. instead of 4.0)

val format_float : string -> float -> string
val my_string_of_float : float -> string
val my_string_of_float_precision : float -> int -> string
val my_print_float : float -> 'a -> unit
val get_extension : string -> string

returns the extension of a filename

val chop_ext_no_excp : string -> string
val remove_extension : string -> string
val cartesian_product : 'a list -> 'a list -> ('a -> 'a -> 'b) -> 'b list
val union_find : ('a list -> 'a0 list -> bool) -> 'a0 list list -> 'a list list
val from_char_pos_to_line_and_col : string -> int -> bool -> string * string
val skip_cr : char Stream.t -> int -> int -> int -> bool -> string * string
val get_new_line_number : char Stream.t -> int -> int
val search_int : char list -> int option
val search_int_acc : string -> char list -> int option
type my_create_process_result =
  1. | OK
  2. | KO
  3. | PID of int
val my_create_process : ?std_in:Unix.file_descr -> ?std_out:Unix.file_descr -> ?std_err:Unix.file_descr -> ?wait:bool -> string -> string list -> my_create_process_result
val gv : string -> unit

gv ps_file calls the post-script visualizer gv on ps_file.

val pdf : string -> unit

pdf file calls the pdf visualizer xpdf on file.

val dot : string -> string -> int

dot dot_file ps_file calls dot on dot_file and produce its result in pd_file

val get_fresh_dir : string -> string
val exe : unit -> string
val tabulate_result : ('a, 'b) Stdlib.Hashtbl.t Stdlib.ref -> int Stdlib.ref -> int -> ('a -> 'b) -> 'a -> 'b
val print_fl : Stdlib.out_channel -> float list -> unit
val print_fll : Stdlib.out_channel -> float list list -> unit
val transpose : 'a list list -> 'b list list
val safe_remove_file : string -> unit
val entete : string -> string -> string
val generate_up_and_down_macro : string -> unit
val rm_dir : Stdlib.out_channel -> string -> unit
val get_io_from_lustre : string -> string option -> (string * string) list * (string * string) list
val overflow_msg : string -> unit
val int_of_string : string -> int
val int_of_num : Num.num -> int
val usage_out : (Stdlib.Arg.key * Stdlib.Arg.spec * Stdlib.Arg.doc) list -> Stdlib.Arg.usage_msg -> unit
val big_max_int : Big_int.big_int
val my_int_of_string : string -> int