Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: arrange lists side by side

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56584] Re: [mg56538] arrange lists side by side
  • From: John Kiehl <john.kiehl at soundtrackny.com>
  • Date: Fri, 29 Apr 2005 03:21:27 -0400 (EDT)
  • Reply-to: John Kiehl <john.kiehl at soundtrackny.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Your problem immediately made me think of MapIndexed[ ] which uses a second parameter (#2) to refer to the position of each element that's being Mapped onto.  There's an inelegant  detail with subtracting 1 and adding 1, as well as needing Sequence[] to get the bracketing as desired.


On Thursday, April 28, 2005 2:40 AM, marloo3 at mail15.com wrote:
>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}}
>
>----------------------------------------------------------------------
>
>
>



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