<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/12/ea8e202bbe21bf899ca6dcb2d59b0c8d"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-12-05T02:01:07"
  subject="[Caml-list] lazy computation problem"
  prev="2003/12/bee38859b007b41ffefe31e5b16980d4"
  next="2003/12/74f05144c7fc815d582c633fa4b557ac"
  next-in-thread="2003/12/74f05144c7fc815d582c633fa4b557ac"
  prev-thread="2003/12/e4ffe98ad674659fd303b53d209bccd5"
  next-thread="2003/12/f95e21d4439f6a407a7b0fba2f509364"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] lazy computation problem">
<msg 
  url="2003/12/ea8e202bbe21bf899ca6dcb2d59b0c8d"
  from="Pietro Abate &lt;Pietro.Abate@a...&gt;"
  author="Pietro Abate"
  date="2003-12-05T02:01:07"
  subject="[Caml-list] lazy computation problem">
<msg 
  url="2003/12/74f05144c7fc815d582c633fa4b557ac"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-12-05T03:24:46"
  subject="Re: [Caml-list] lazy computation problem">
</msg>
</msg>
</thread>

<contents>
Hi all.
I'm trying to learn how to programm lazily, but I'm kinda stuck.
I've a list, say let l = [[1;2;3];[4;5];[6;7;8]] and I want to
produce all possibile permutations (1,4,6) (1,4,7) (1,4,8) (1,5,6)
(1,5,7) ...

it can easily be done with List.iter and a couple of recoursive steps,
but I'm trying to code it in a tail-recoursive style and using lazy
evaluation. Hence my problem is to write a function that gets the list
and gives me back one result (1,4,6) and a lazy structure that encode
the rest of the computation... I looked at lazy streams or lazy lists to
solve this problem, but I was unable to come up with any nice
solution...

does anybody have any hints ?

p

ps: this problem is a stripped down version of a more complicated one
that involves big data structures, that's why I'm trying to come up with
an optimized solution.

-- 
++ As I grow older, I pay less attention to what men say.
   I just watch what they do. Andrew Carnegie (1835-1919).
++ Please avoid sending me Word or PowerPoint attachments.
   See http://www.fsf.org/philosophy/no-word-attachments.html

-------------------
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

</contents>

</message>

