Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

Re: more elements in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32261] Re: [mg32241] more elements in a list
  • From: BobHanlon at aol.com
  • Date: Wed, 9 Jan 2002 23:37:16 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 1/9/02 3:37:06 AM, cabanc at hotmail.com writes:

>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}
>

Flatten[Table[#[[1]], {#[[2]]}] & /@ Transpose[{{a, b, c}, {2, 5, 4}}]]

or

Flatten[Inner[Table[#1, {#2}] &, {a, b, c}, {2, 5, 4}, List ]]

Bob Hanlon
Chantilly, VA  USA


  • 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