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] lazy computation problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@a...>
Subject: [Caml-list] lazy computation problem
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

does anybody have any hints ?


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.

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