Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: ocaml ml <caml-list@inria.fr>
Subject: [Caml-list] lazy computation problem
Date: Fri, 5 Dec 2003 13:01:12 +1100	[thread overview]
Message-ID: <20031205020112.GA11913@anu.edu.au> (raw)

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


             reply	other threads:[~2003-12-05  2:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-05  2:01 Pietro Abate [this message]
2003-12-05  3:24 ` Nicolas Cannasse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031205020112.GA11913@anu.edu.au \
    --to=pietro.abate@anu.edu.au \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox