Module Fun

module Fun: sig .. end
This module provides an implementation of functions on integers.
Author(s): Michele Sevegnani

type +'a t 
Type of functions on integers.

Standard map operations



These functions are described in the standard library.
val empty : int t
val is_empty : int t -> bool
val mem : int -> int t -> bool
val add : int -> int -> int t -> int t
val iter : (int -> int -> unit) -> int t -> unit
val fold : (int -> int -> 'b -> 'b) -> int t -> 'b -> 'b
val cardinal : int t -> int

Additional functions


val dom : int t -> IntSet.t
Return the domain of a function.
val codom : int t -> IntSet.t
Return the codomain of a function.
val inverse : int t -> IntSet.t Rel.t
Return the inverse of a function. Note that the inverse of a function is, in the general case, a binary relation.
val to_list : int t -> (int * int) list
Return the list of pairs defined by a function.
val of_list : (int * int) list -> int t
Inverse of Fun.to_list. Note that in case of clashing pairs only the right-most is used.
val parse : int list -> int t
parse l returns a function in which the numbers from 0 to n - 1 (with n the length of l) are mapped to the elements of l, in the given order. Example:

parse [0;0;3;1;2] = [(0,0);(1,0);(2,3);(3,1);(4,2)].

val to_string : int t -> string
Return the string representation of a function. Example: "{(1, 2), (2, 3),
    (3, 3)}"
.
val equal : int t -> int t -> bool
Equality between functions.
val compare : int t -> int t -> int
Comparison between functions.
val apply_exn : int t -> int -> int
apply_exn f x returns f(x).
Raises Not_found if f is not defined for x.
val apply : int t -> int -> int option
Same as Fun.apply_exn but with error-aware return type.
val transform_exn : int t -> int Iso.t -> int Iso.t -> int t
transform_exn f iso_d iso_c returns the function obtained by applying iso_d and iso_c to the domain and codomain of f, respectively.
Raises Not_found if the isomorphisms are undefined.
val is_total : int -> int t -> bool
Return true if a function is total, false otherwise.
val check_codom : int -> int -> int t -> bool
check_codom min max f returns true if the codomain of f is in the range [min, max].