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: Re: more elements in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32287] Re: [mg32263] Re: [mg32241] more elements in a list
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Fri, 11 Jan 2002 04:35:22 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Since my first answer was a bit too much like everyone else's, here is 
one that is a little more original :)

In[2]:=
l1={a,b,c};
l2={2,5,4};

In[6]:=
Flatten[l1^l2/.Power[x_,n_]:>Table[x,{n}]]

Out[6]=
{a,a,b,b,b,b,b,c,c,c,c}


On Thursday, January 10, 2002, at 01:37  PM, Andrzej Kozlowski wrote:

> Lots of different ways, I am sure. Here is just the first one I came up
> with:
>
> In[2]:=
> l1={a,b,c};
>
> In[3]:=
> l2={2,5,4};
>
> In[4]:=
> Flatten[Inner[Table[#,{#2}]&,l1,l2,List]]
>
> Out[4]=
> {a,a,b,b,b,b,b,c,c,c,c}
>
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
>
> On Wednesday, January 9, 2002, at 05:17  PM, 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
>>
>>
>>
>>
>
>
>



  • Prev by Date: Odd phenomenon but not serious
  • Next by Date: Re: arguments/realtime3d
  • Previous by thread: Re: more elements in a list
  • Next by thread: Re: more elements in a list