RE: more elements in a list
- To: mathgroup at smc.vnet.net
- Subject: [mg32273] RE: [mg32241] more elements in a list
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 9 Jan 2002 23:37:40 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Merkat,
Here is one method:
list1 = {{a, b, c}, {2, 5, 4}} // Transpose
{{a, 2}, {b, 5}, {c, 4}}
list1 /. {sym_, n_Integer} :> Array[sym & , n]// Flatten
{a, a, b, b, b, b, b, c, c, c, c}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
> From: merkat [mailto:cabanc at hotmail.com]
To: mathgroup at smc.vnet.net
>
> 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
>