Module Util

module Util: sig .. end
Utility functions for problem set 3.


timing


val time : ('a -> 'b) -> 'a -> float
time f x runs f x and returns the time it takes to run (in seconds).

randomization


val rand_list : int -> int -> int list
rand_list n l returns a random list of l integers between 0 and n
val shuffle : 'a list -> 'a list
randomly shuffle a list.
val choice : 'a list -> 'a
randomly select an element from a list

comparisons


type comparison_result = 
| Lt (*Less than*)
| Eq (*Equal to*)
| Gt (*Greater than*)
type 'a comparator = 'a -> 'a -> comparison_result 
An 'a comparator represents a total order on 'as.

printing


val string_of_list : ('a -> string) -> 'a list -> string
string_of_list f l returns a pretty joining of f invoked on every element of l.