arranging list items

Q&A's, tips, howto's
Locked
tomtoo
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

arranging list items

Post by tomtoo »

hi guys,

I'm making a directory structure and an outline.
I have the index positions of items in lists:

Code: Select all

> 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
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: arranging list items

Post by jopython »

Your intentions are not clear in your example.

tomtoo
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

Re: arranging list items

Post by tomtoo »

jopython wrote: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

Code: Select all

       0
       |
      / \
  1   3    6__
  |   |       |
  2   |       |	
       |       |
       |       |
      / \      |
     4   5     |
                |
                |
              /  \
           |  |  |  |
           |  |  |  | 
           7  8  9  10
I hope that's a little bit more clear...

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: arranging list items

Post by jopython »

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

tomtoo
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

Re: arranging list items

Post by tomtoo »

jopython wrote: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
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: arranging list items

Post by HPW »

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
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

Re: arranging list items

Post by tomtoo »

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
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: arranging list items

Post by HPW »

did 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
Posts: 46
Joined: Wed Oct 28, 2009 10:00 pm

Re: arranging list items

Post by tomtoo »

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...

Locked