I defined the following sequences:
datatype 'a DSeq = DNil | DCons of 'a * (unit -> 'a DSeq) * (unit -> 'a DSeq)
datatype 'a Seq = Nil | Cons of 'a * (unit -> 'a Seq)
The first one can be thought as a function that gives the next x axis element and another function that gives the next y axis array.
I’m trying to write a function that gets a DSeq and convert it to Seq but in diagonal for example
DSeq: s = 1 2 3
4 5 6
7 8 9
Myfun s = 1 2 4 3 5 7 6 8 9
Of course this is just a representation example and not in sml syntax.
How can I do it without evaluate the same elements over and over again in order to get to the correct index I’m searching in each step?