Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-04-28 (14:31)
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)

  p:'a -> unit
  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,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: