From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA09530; Thu, 23 May 2002 20:56:28 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA09397 for ; Thu, 23 May 2002 20:56:27 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from tenerife.ics.uci.edu (tenerife.ics.uci.edu [128.195.38.127]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4NIuQD14786 for ; Thu, 23 May 2002 20:56:26 +0200 (MET DST) Received: (from reig@localhost) by tenerife.ics.uci.edu (8.11.6/8.11.6/SuSE Linux 0.5) id g4NIt5Q24317; Thu, 23 May 2002 11:55:05 -0700 Date: Thu, 23 May 2002 11:55:05 -0700 Message-Id: <200205231855.g4NIt5Q24317@tenerife.ics.uci.edu> X-Authentication-Warning: tenerife.ics.uci.edu: reig set sender to reig@ics.uci.edu using -f From: Fermin Reig To: vinfoley@iquebec.com CC: caml-list@inria.fr In-reply-to: <20020523182450.GA18222@vincent> (message from Vincent Foley on Thu, 23 May 2002 14:24:50 -0400) Subject: Re: [Caml-list] Hash tables keys and values References: <20020523182450.GA18222@vincent> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Once I have my hash table complete, I would like to print each key > with its associated value. How would I do this? Right now I only > have the values: > > Hashtbl.iter (fun k -> Printf.printf "%d\n") myhash; > > Is there any way I could print both keys and values? > > Thank you, > Vincent Foley Read the OCaml manual: val iter : ('a -> 'b -> unit) -> ('a, 'b) Hashtbl.t -> unit Hashtbl.iter f tbl applies f to all bindings in table tbl. F RECEIVES THE KEY AS FIRST ARGUMENT, AND THE ASSOCIATED VALUE AS SECOND ARGUMENT. The order in which the bindings are passed to f is unspecied. Each binding is presented exactly once to f. (My emphasis) Hope that helps, Fermin ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners