Page 1 of 1

arranging list items

Posted: Sat Nov 02, 2013 9:31 pm
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?

Re: arranging list items

Posted: Sun Nov 03, 2013 1:11 am
by jopython
Your intentions are not clear in your example.

Re: arranging list items

Posted: Sun Nov 03, 2013 3:55 am
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...

Re: arranging list items

Posted: Sun Nov 03, 2013 4:27 am
by jopython
And how would be the final desired list look like for this example?

Re: arranging list items

Posted: Sun Nov 03, 2013 4:43 am
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))

Re: arranging list items

Posted: Sun Nov 03, 2013 6:49 am
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

Re: arranging list items

Posted: Sun Nov 03, 2013 11:14 am
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...

Re: arranging list items

Posted: Sun Nov 03, 2013 12:23 pm
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.

Re: arranging list items

Posted: Mon Nov 04, 2013 10:53 pm
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...