more hash functions

This commit is contained in:
Simon Cruanes 2014-06-23 23:40:10 +02:00
parent 1beab5268b
commit b56cdfa17a
2 changed files with 10 additions and 0 deletions

View file

@ -69,9 +69,15 @@ let rec list_ f l s = match l with
let array_ f a s = Array.fold_right f a s let array_ f a s = Array.fold_right f a s
let opt f o h = match o with
| None -> h
| Some x -> f x h
let pair h1 h2 (x,y) s = h2 y (h1 x s) let pair h1 h2 (x,y) s = h2 y (h1 x s)
let triple h1 h2 h3 (x,y,z) s = h3 z (h2 y (h1 x s)) let triple h1 h2 h3 (x,y,z) s = h3 z (h2 y (h1 x s))
let if_ b then_ else_ h =
if b then then_ h else else_ h
type 'a sequence = ('a -> unit) -> unit type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option type 'a gen = unit -> 'a option
type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist] type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]

View file

@ -61,9 +61,13 @@ val list_ : 'a hash_fun -> 'a list hash_fun
val array_ : 'a hash_fun -> 'a array hash_fun val array_ : 'a hash_fun -> 'a array hash_fun
val opt : 'a hash_fun -> 'a option hash_fun
val pair : 'a hash_fun -> 'b hash_fun -> ('a * 'b) hash_fun val pair : 'a hash_fun -> 'b hash_fun -> ('a * 'b) hash_fun
val triple : 'a hash_fun -> 'b hash_fun -> 'c hash_fun -> ('a * 'b * 'c) hash_fun val triple : 'a hash_fun -> 'b hash_fun -> 'c hash_fun -> ('a * 'b * 'c) hash_fun
val if_ : bool -> 'a hash_fun -> 'a hash_fun -> 'a hash_fun
(** Decide which hash function to use depending on the boolean *)
type 'a sequence = ('a -> unit) -> unit type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option type 'a gen = unit -> 'a option
type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist] type 'a klist = unit -> [`Nil | `Cons of 'a * 'a klist]