Hi,
I have been looking at some graph code in ML and Haskell (I think) and
have seen that lazy evaluation plays an important role when we are
dealing with cyclic DAGs (infinite structures). I then looked at the
O'Reilly book to see how one could do this in OCaml.
The book shows in page 109 "Infinite" data structures how this can be
done. However I also see we have the Lazy module. I did some
experimenting with this technique and cannot seem to use it to good
effect. The example I though of was identifying a sequence of two odd
numbers whose sum is 12 (=5+7). To do this I figured something like this:
(x,y) = sum_12_pair ( odd ( generate 0 ) )
generate - generate sequence natural numbers
odd - filter to remove all even numbers
sum_12_pair - test ever consecutive pair for the correct sum
I don't know if the above example can actually be used to experiment
with the realistic use of the Lazy module. Could someone show me how
this can be used in a very simple example (maybe the above is good
enough?) or alternativelly point me to a source with this info?
TIA,
Hugo F.