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 QAA13048; Wed, 28 Apr 2004 16:31:33 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA13049 for ; Wed, 28 Apr 2004 16:31:31 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3SEVSjq020632 for ; Wed, 28 Apr 2004 16:31:29 +0200 Received: from [192.168.1.200] (ppp119-113.lns1.syd2.internode.on.net [150.101.119.113]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3SEV8Zq082501; Thu, 29 Apr 2004 00:01:12 +0930 (CST) Subject: Re: [Caml-list] [ANN] The Missing Library From: skaller Reply-To: skaller@users.sourceforge.net To: Jean-Christophe Filliatre Cc: "Yaron M. Minsky" , Brian Hurt , Martin Berger , The Caml Trade In-Reply-To: <16527.44649.729729.106381@gargle.gargle.HOWL> References: <1083140676.9537.831.camel@pelican.wigram> <1083151902.29774.18.camel@localhost.localdomain> <1083154175.9537.944.camel@pelican.wigram> <16527.44649.729729.106381@gargle.gargle.HOWL> Content-Type: text/plain Message-Id: <1083162666.9537.983.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Apr 2004 00:31:08 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 filliatre:01 iterator:01 val:01 iterator:01 val:01 ignoring:01 'b-:01 hashtbl:01 hastbl:01 9660:01 glebe:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 2004-04-28 at 23:15, Jean-Christophe Filliatre wrote: > skaller writes: > In ocamlgraph we provide depth-first and breadth-first graph traversal > both as HOF and as iterators. Iterators have the following signature: > > ====================================================================== > type iterator > val start : G.t -> iterator > val step : iterator -> iterator > val get : iterator -> G.V.t Perhaps the iterator is actually the triple: (iterator, step, get) Ignoring the lack of termination, you might think to write a function now: let rec print p (it, step, get) = p (get it); print p (step it, step, get) where: p:'a -> unit it:'b step: 'b->'b get: 'b -> 'a val print : 'a -> 'b * ('b -> 'b) * ('b -> 'c) -> 'd = [The 'd will be unit if I trapped termination with an exception] So perhaps it can be done .. although not for Hashtbl. Hastbl.iter is control inverse of what is required. Should work fine for 'Set' using 'choose' function. Works for List. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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