MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: arrange lists side by side

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56623] Re: [mg56591] Re: arrange lists side by side
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Sat, 30 Apr 2005 01:28:05 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Sorry, this is the right way to tell the joke (see below):

>-----Original Message-----
>From: Wolf, Hartmut 
To: mathgroup at smc.vnet.net
>Sent: Friday, April 29, 2005 11:19 AM
>Subject: [mg56623] RE: [mg56591] Re: arrange lists side by side
>
>
>>-----Original Message-----
>>From: Carl K. Woll [mailto:carlw at u.washington.edu] 
To: mathgroup at smc.vnet.net
>>Sent: Friday, April 29, 2005 9:22 AM
>>Subject: [mg56623] [mg56591] Re: arrange lists side by side
>>
>><marloo3 at mail15.com> wrote in message 
>news:d4q1qj$oh8$1 at smc.vnet.net...
>>> Hi
>>> is there a way to spread out a small list over a bigger list 
>>recurrently 
>>> like
>>> this:
>>> a={28, 30, 17};
>>> b={1, 2, 9, 4, 5, 7, 3, 8};
>>> to give the output:
>>> {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}};
>>> the number of items in "b" do not neccesary  multiples of 
>>the number of 
>>> items
>>> in "a"
>>> mark
>>>
>>> okay this is my approach
>>>
>>> a={28,30,17};
>>> b={1,2,9,4,5,7,3,8};
>>> aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}]
>>>
>>> Out[]=
>>> {{28,30,17},{28,30,17}}
>>>
>>> frc=Mod[Length[b],Length[a]];
>>> gg=Flatten[Join[aa,Part[a,{1,frc}]]];
>>> Transpose[Join[{b},{gg}]]
>>>
>>> Out[]=
>>> {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}
>>>
>>> 
>>----------------------------------------------------------------------
>>>
>>>
>>
>>Undoubtedly you will get a lot of responses. Here is one more.
>>
>>Transpose[ PadRight[ {{}}, {2, Length[b]}, {b,a} ] ]
>>
>>Carl Woll 
>>
>>
>>
>
>my first idea, quite similar, was this:
>
>In[5]:= Transpose[{b, PadRight[{}, Length[b], a]}]
>Out[5]=
>{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 
>28}, {8, 30}}
>
>
>This however is a bit obfuscated:
>
>In[15]:= First@ListCorrelate[b, a, {1, Length[a]}, a, List, List]
>Out[15]=
>{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 
>28}, {8, 30}}
>
Perhaps this was more appropriate:

  ListCorrelate[b, a, {1, Length[a]}, a, List, Sequence]



>or this
>
>In[30]:=
>Transpose@Prepend[Partition[a, Length[b], Length[b], {1, 1}, a], b]
>Out[30]=
>{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 
>28}, {8, 30}}
>
>
>--
>Hartmut
>


  • Prev by Date: Re: Re: arrange lists side by side
  • Next by Date: Re: Using BarChart in a Widget
  • Previous by thread: Re: Re: arrange lists side by side
  • Next by thread: Can't Get a numric answer for this