arranging list items

Started by tomtoo, November 02, 2013, 02:31:55 PM

Previous topic - Next topic

tomtoo

hi guys,



I'm making a directory structure and an outline.

I have the index positions of items in lists:

> sub1
(0 11 18)
> sub2
(1 3 6 12 14 15 19 21)
> sub3
(2 4 5 7 8 9 10 13 16 17 20)


elements in sub1 are the top-level directories

sub2 elements are subdirectorys of sub1 elements

sub3 elements are subdirectories of sub2 elements



I'm close, but stuck. any suggestions?

jopython

#1
Your intentions are not clear in your example.

tomtoo

#2
Quote from: "jopython"Your intentions are not clear in your example.

sorry.



I would like to combine these lists so that



1, 3, and 6 would be nested under 0

2 would be nested under 1

4 and 5 would be nested under 3

7 8 9 and 10 would be nested under 6



here's a terrible diagram

      0
       |
      /
  1   3    6__
  |   |       |
  2   |       |
       |       |
       |       |
      /       |
     4   5     |
                |
                |
              /  
           |  |  |  |
           |  |  |  |
           7  8  9  10


I hope that's a little bit more clear...

jopython

#3
And how would be the final desired list look like for this example?

tomtoo

#4
Quote from: "jopython"And how would be the final desired list look like for this example?


I think something like this:



'((0 (1(2))(3(4 5))(6(7 8 9 10)))(11(12(13))(14)(15(16 17)))(18(19(20)))(21))

HPW

#5
Not sure what you want but from your Diagramm I would make this:



'(0((1(2))(3(4 5))(6(7 8 9 10))))



Each Level contains a sub-list.



Regards
Hans-Peter

tomtoo

#6
I didn't include all the elements from the op in the diagram. do you mean make three different combined lists, or did you only include the elements in the diagram?



now, how to do it...

HPW

#7
Quotedid you only include the elements in the diagram?


Yes, I only include them, because that was the clear structure to me.

When there are more elements in a Level, you add them to the same list-Level.

And they carry their own sub-elements.
Hans-Peter

tomtoo

#8
I'm still not sure of the best way to create a new list by combining sub1 sub2 and sub3. Is this a job for "array?" an example would be appreciated...