How can I split a List into sub-lists

View: New views
3 Messages — Rating Filter:   Alert me  

How can I split a List into sub-lists

by Zsolt Koppany :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I would like to split a list like below:

{A1 A2 A3 B1 B2 B3} into

{
 {A1 B1}
 {A2 B2}
 {A3 B3}
}

Which class can do that?

Zsolt


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: How can I split a List into sub-lists

by CloD :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The right answer is : you can do it yourself, with or without class.

For instance (pseudocode) :

left = list.sublist(0,middle)
right = list.sublist(middle,end)
for i in {0..length}
    result.add(new list({left(i),right(i)}))

that difficult?


    Claude

Le jeudi 05 juin 2008 à 20:41 +0200, Zsolt Koppany a écrit :

> Hi,
>
> I would like to split a list like below:
>
> {A1 A2 A3 B1 B2 B3} into
>
> {
>  {A1 B1}
>  {A2 B2}
>  {A3 B3}
> }
>
> Which class can do that?
>
> Zsolt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: How can I split a List into sub-lists

by Thorbjørn Ravn Andersen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Zsolt Koppany skrev  den 05-06-2008 20:41:

> Hi,
>
> I would like to split a list like below:
>
> {A1 A2 A3 B1 B2 B3} into
>
> {
>  {A1 B1}
>  {A2 B2}
>  {A3 B3}
> }
>
> Which class can do that?
>  
ArrayList of ArrayList?

Naturally depends on your exact criteria of what goes where in which order.

--
  Thorbjørn

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...