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 PAA09189; Wed, 28 Apr 2004 15:39:04 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 PAA09167 for ; Wed, 28 Apr 2004 15:39:03 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3SDd2YM027622 for ; Wed, 28 Apr 2004 15:39:02 +0200 Received: from pc8-123 (pc8-123 [129.175.8.123]) by lri.lri.fr (8.12.10/jtpda-5.4) with ESMTP id i3SDFMCr017254 ; Wed, 28 Apr 2004 15:15:31 +0200 (MEST) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 1BIouH-0003EP-00; Wed, 28 Apr 2004 15:15:21 +0200 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <16527.44649.729729.106381@gargle.gargle.HOWL> Date: Wed, 28 Apr 2004 15:15:21 +0200 To: skaller@users.sourceforge.net Cc: "Yaron M. Minsky" , Brian Hurt , Martin Berger , The Caml Trade Subject: Re: [Caml-list] [ANN] The Missing Library In-Reply-To: <1083154175.9537.944.camel@pelican.wigram> References: <1083140676.9537.831.camel@pelican.wigram> <1083151902.29774.18.camel@localhost.localdomain> <1083154175.9537.944.camel@pelican.wigram> X-Mailer: VM 7.03 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-MailScanner: Found to be clean X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 caml-list:01 iterator:01 iterator:01 abstraction:01 systematic:01 val:01 val:01 implemented:01 lri:01 filliatr:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk skaller writes: > > > > I'm wondering what concepts Ocaml can't express/enforce? > > > > > > Iterators. > > > > Why can't you do this kind of in ocaml? Returning something like a > > "next" function would seem to give you a very basic (but usable) > > iterator. Which part of the iterator abstraction can't you do? > > I suggest you try it. I don't know how to answer the question. Perhaps I missed something in this thread but it is not so difficult to write iterators in ocaml (of course it can not be done in a systematic way --- may be that was John's point). 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 ====================================================================== (where G.t is the type of graphs). It was a lot of fun coding these itearators, and very useful to write a backtracking algorithm to colors graphs. It was particularly easy as iterators are implemented as persistent data structures: thus there is no `undo' part in the backtracking code. I guess one cannot write a backtracking algorithm using the usual HOF fold function. If one is interested the code is here: http://www.lri.fr/~filliatr/ocamlgraph/ -- Jean-Christophe Filliātre ------------------- 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