Hi Karim, sorry I used a simple example, the actual task is more complicated. I’ll describe it here:
I’m working on a program to import a piece in XML, and then create a list of lists, each element being a thruple in the form (duration onset offset), where offset = onset + duration. I already accomplished it.
Here’s the fragment I’m using as a test:
After running it through my program, I got this:
Each line represents an onset (which is the MIDDLE number on each thruple).
My goal is to iterate over the indices, starting at the second element (i=1) and ask the following question:
“In the line BEFORE this one, is there any thruple on which the OFFSET (third element) is greater than the CURRENT onset? If YES, I want to append said thruple on the current line”
The thing is, when I move on to the next index, I want my original list to already have the thruple appended, so it can be checked again. For instance:
Here. if my index is the one poiting to the line ((1000 5000 6000)), I’ll find that the item (3000 4000 7000) has a greater ending (7000) than the current one. So, I’ll append it, making the current line ((1000 5000 6000) (3000 4000 7000))
When I move on to line ((1000 6000 7000)), I’m going to do the check on the previous line, and I want it to SEE the (3000 4000 7000) element, to check the condiditon, and append it, this time to the current line.
My final result (this was done by hand just as to show the desired output) should be this: