Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] [ANN] The Missing Library
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 = <fun>

[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