Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Use of Hashtbl
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Francois Thomasset <francois.thomasset@i...>
Subject: [Caml-list] Use of Hashtbl
Hi
I can't explain the following behavior of add in module Hashtbl.
What I would like to have is an implementation of a set of strings: insertion, 
test for membership, print funtion of the set. I know I could use the Set 
module, but I don't really need to be applicative. Anyway I wonder what's 
wrong with the code below.

module T = Hashtbl ;;
let hashtable : (string,unit) T.t = T.create 128 ;;
# T.add hashtable "un" ();;
- : unit = ()
# T.add hashtable "deux" ();;
- : unit = ()
# T.mem hashtable "un";;  
- : bool = true
# T.mem hashtable "deux";;   
- : bool = true
# T.clear hashtable;;
- : unit = ()

Fine. Now I add my strings all in one shot:
# T.add hashtable "un" ();; T.add hashtable "deux" ();;
- : unit = ()
# T.mem hashtable "un";;  
- : bool = true
# T.mem hashtable "deux";;   
- : bool = false
I must have missed something... Where is "deux"?

					François Thomasset.
					INRIA (A3)

Tel: +33 (1) 39-63-54-75
Fax: +33 (1) 39-63-53-30 ou +33 (1) 39-63-59-95
Email: Francois.Thomasset@inria.fr
Smail: INRIA, Rocquencourt, BP 105, 78153 Le Chesnay Cedex, France


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr