MathGroup Archive 2005

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

Search the Archive

Re: arrange lists side by side

  • To: mathgroup at
  • Subject: [mg56681] Re: [mg56538] arrange lists side by side
  • From: John Kiehl <john.kiehl at>
  • Date: Tue, 3 May 2005 05:26:33 -0400 (EDT)
  • Reply-to: John Kiehl <john.kiehl at>
  • Sender: owner-wri-mathgroup at

Somehow, my post from yesterday didn't include the actual line of Mathematica code. So here it is again.

Your problem immediately made me think of using MapIndexed[ ] which uses a second parameter (#2) to refer to the position of each element that's being Mapped onto.  I use that position information to refer to the appropriate member of the shorter list. ( There's an inelegant  detail with subtracting 1 inside the Mod[ ] and adding 1 outside the Mod[ ], as well as needing Sequence[] to get the bracketing as desired, but I've grown use to these details with MapIndexed[ ]. )

So, using your a and b as defined:

In[] = MapIndexed[{#,  Sequence @@ a[[ Mod[#2-1,Length[a]] +1]] }&, b ]

john kiehl

On Thursday, April 28, 2005 2:40 AM, marloo3 at wrote:
>is there a way to spread out a small list over a bigger list recurrently like 
>a={28, 30, 17};
>b={1, 2, 9, 4, 5, 7, 3, 8};
>to give the output:
>the number of items in "b" do not neccesary  multiples of the number of items 
>in "a"
>okay this is my approach

  • Prev by Date: Re: Interpreting output
  • Next by Date: A bug in the documentation?
  • Previous by thread: Re: Reading from a file.
  • Next by thread: A bug in the documentation?