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: [mg32282] Re: [mg32241] more elements in a list
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Wed, 9 Jan 2002 23:38:09 -0500 (EST)
  • References: <200201090817.DAA23662@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Two immediate possibilities (someone will come up with a more elegant
solution):

In[1]:=
list1={a,b,c};
list2={2,5,4};
In[2]:=
Flatten[Table[Table[list1[[j]],{list2[[j]]}],{j,1,3}]]
Out[2]=
{a,a,b,b,b,b,b,c,c,c,c}
In[3]:=
Flatten[Inner[List,list1,list2,List]/.{x_,y_}->Table[x,{y}]]
Out[3]=
{a,a,b,b,b,b,b,c,c,c,c}

Tomas Garza
Mexico City
----- Original Message -----
From: "merkat" <cabanc at hotmail.com>
To: mathgroup at smc.vnet.net
Subject: [mg32282] [mg32241] more elements in a list


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



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