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: [mg32390] RE: [mg32241] more elements in a list
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.de>
  • Date: Fri, 18 Jan 2002 00:17:36 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Merkat,

There have been quite a few answers on this problem. Here is another one:

In[1001]:=
Thread[Unevaluated[NestList[Sequence,Join[a,b,c],Join[1,4,3]]],Join]

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

You have to specify repetions then, instead of number of occurrences. If you
don't like this, add the precomputation for that:

In[2002]:=
Unevaluated[
    Thread[Unevaluated[NestList[Sequence,xx,yy]],Join]]/.
    {xx->Join@@{a,b,c}, yy->Join@@({2,5,4}-1)}

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

But, alas, this solution will not allow for zero occurrances  ;-)
--
Hartmut


> -----Original Message-----
> From:	merkat [SMTP:cabanc at hotmail.com]
To: mathgroup at smc.vnet.net
> Sent:	Wednesday, January 09, 2002 9:18 AM
> To:	mathgroup at smc.vnet.net
> Subject:	[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: Exploring Analytic Geometry by Vossler
  • Next by Date: Re: Taylor Series Expansions
  • Previous by thread: more elements in a list
  • Next by thread: Logit Probit in Mathematica