mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCHash.map
This commit is contained in:
parent
4db9d4eccb
commit
f5505297de
2 changed files with 14 additions and 0 deletions
|
|
@ -124,6 +124,7 @@ let array f l = Array.fold_left (combine f) 0x42 l
|
|||
let pair f g (x,y) = combine2 (f x) (g y)
|
||||
let triple f g h (x,y,z) = combine2 (combine2 (f x) (g y)) (h z)
|
||||
let quad f g h i (x,y,z,w) = combine2 (combine2 (f x) (g y)) (combine2 (h z) (i w))
|
||||
let map f h x = h (f x)
|
||||
|
||||
let if_ b then_ else_ h =
|
||||
if b then then_ h else else_ h
|
||||
|
|
|
|||
|
|
@ -50,6 +50,19 @@ val pair : 'a t -> 'b t -> ('a * 'b) t
|
|||
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
|
||||
val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
|
||||
|
||||
val map : ('a -> 'b) -> 'b t -> 'a t
|
||||
(** [map f h] is the hasher that takes [x],
|
||||
and uses [h] to hash [f x].
|
||||
|
||||
For example:
|
||||
{[
|
||||
module Str_set = Set.Make(String)
|
||||
|
||||
let hash_str_set : Str_set.t CCHash.t = CCHash.(map Str_set.to_seq @@ seq string)
|
||||
]}
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val if_ : bool -> 'a t -> 'a t -> 'a t
|
||||
(** Decide which hash function to use depending on the boolean. *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue