From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA21679; Fri, 5 Dec 2003 03:01:07 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA21326 for ; Fri, 5 Dec 2003 03:01:06 +0100 (MET) Received: from anu.edu.au (anumail5.anu.edu.au [150.203.2.45]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hB5214106230 for ; Fri, 5 Dec 2003 03:01:04 +0100 (MET) Received: from pulp.anu.edu.au (pulp.anu.edu.au [150.203.126.25]) by anu.edu.au (8.12.10/8.12.10) with ESMTP id hB5211B2017833 for ; Fri, 5 Dec 2003 13:01:02 +1100 (EST) Received: from pulp.anu.edu.au (localhost [127.0.0.1]) by pulp.anu.edu.au (8.12.10/8.12.10/Debian-5) with ESMTP id hB521C2R012366 for ; Fri, 5 Dec 2003 13:01:12 +1100 Received: (from abate@localhost) by pulp.anu.edu.au (8.12.10/8.12.10/Debian-5) id hB521CcY012363 for caml-list@inria.fr; Fri, 5 Dec 2003 13:01:12 +1100 Date: Fri, 5 Dec 2003 13:01:12 +1100 From: Pietro Abate To: ocaml ml Subject: [Caml-list] lazy computation problem Message-ID: <20031205020112.GA11913@anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.4i X-Spam-Status: Scanned X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on pulp.anu.edu.au X-Sender: abate@pulp.anu.edu.au X-Sender-Domain: pulp.anu.edu.au X-Spam-Score: (-2.9) X-Spam-Tests: USER_AGENT_MUTT X-Scanned-By: MIMEDefang 2.36 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pietro:01 abate:01 pietro:01 abate:01 lazily:01 possibile:99 permutations:01 encode:01 lazy:02 lazy:02 optimized:02 men:97 philosophy:02 iter:03 anybody:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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