Re: more elements in a list
- To: mathgroup at smc.vnet.net
- Subject: [mg32279] Re: [mg32241] more elements in a list
- From: Omega Consulting <omega_consulting at yahoo.com>
- Date: Wed, 9 Jan 2002 23:38:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
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