English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
make[1]: warning: Clock skew detected. Your build may be incomplete.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-09-07 (10:32)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: Re: [Caml-list] Equality/Hashtable for functions (inline help feature)

> Note that you cannot use hashtables, as the default hash function will
> fail on functions, but you can use an association list with physical
> equality.

I dont understand why the hash function fails on functions. When I call
Hashtbl.hash : 'a -> int with a function I get an integer. Does it mean
the integer could change while the program is running ?

# Hashtbl.hash (fun x -> x + 1);;
- : int = 151020553
# Hashtbl.hash (fun x -> x + 2);;
- : int = 151020609
# Hashtbl.hash (fun x y -> x + y);;
- : int = 151020669

I had in mind a reduction of the search space based on the hash value and
an association list with physical equallity test on the functions that
have the same hash (collisions).

        Diego Olivier