MathGroup Archive 2002

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

Search the Archive

Re: more elements in a list


At 02:17 AM 1/9/2002, merkat wrote:
>Hi ,
>
>How do I multiply the number of elements in a list?
>I have the lists:
>{a,b,c}  and
>{2,5,4}
>
>the result should be:
>{a,a,b,b,b,b,b,c,c,c,c}
>
>Merkat

Looks like a job for the often overlooked MapThread.

letters={a,b,c};
numbers={2,5,4};

Flatten[MapThread[Table[#1,{#2}]&, {letters, numbers}]]

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"

Spend less time searching and more time finding.
http://www.wz.com/internet/Mathematica.html



  • Prev by Date: Re: more elements in a list
  • Next by Date: RE: more elements in a list
  • Previous by thread: Re: more elements in a list
  • Next by thread: RE: more elements in a list