On Tue, Jun 1, 2010 at 22:54, Philippe Sigaud <[email protected]>wrote:

> I also found the (simple?) problem to enumerate a range of ranges to be
> more interesting than I thought.
> Given a range of ranges ... of ranges, of whatever rank, recursively
> enumerate it:
>
> [[a,b,c],[d,e,f],[g,h,i]]
>
> produce:
>
> (a,0,0),(b,0,1), (c,0,2),(d,1,0), ...
>
> the coordinates of each element, if you will. I have a working version now,
> but it sure taught me that my vision of recursion was flawed.
>
>
Ow, I meant, while conserving the original topology, not as a flat range:

[[(a,0,0),(b,0,1),(c,0,2)],
 [(d,1,0), (e,1,1),(f,1,2)],
 [(g,2,0), (h,2,1),(i,2,2)]]

Lazily, of course.
I wanted the to conserve the rank because

1- that was the goal of the module: map, produce, etc range of ranges
2- it allowed me to iterate to a 'line' and then descend into this
particular line.
3- the original idea was to generate an infinite n-dim grid of coordinates

Philippe

Reply via email to