MathGroup Archive 2005

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

Search the Archive

Re: "expanding a list"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57911] Re: "expanding a list"
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 12 Jun 2005 04:34:37 -0400 (EDT)
  • References: <d8bd00$fj0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Mark,

I think the following lines do the trick (first we create some data,
then we define a function called "listExpand"):

In[1]:=
data = {1.02, 5.7, 3.987, 4.212, 9.11}

Out[1]=
{1.02,5.7,3.987,4.212,9.11}

In[2]:=
listExpand[L_, r_, s_] := FlattenAt[{Table[L[[1]], {r}],
     (Table[#1, {s}] & ) /@ Rest[L]}, 2];

In[3]:=
listExpand[data, 3, 5]

Out[3]=
{{1.02,1.02,1.02},{5.7,5.7,5.7,5.7,5.7},{3.987,3.987,
    3.987,3.987,3.987},{4.212,4.212,4.212,4.212,4.212},{
    9.11,9.11,9.11,9.11,9.11}}


  • Prev by Date: Re: saving the kernel
  • Next by Date: Re: Applying function to nested lists
  • Previous by thread: Re: "expanding a list"
  • Next by thread: Re: "expanding a list"