Re: "expanding a list"
- To: mathgroup at smc.vnet.net
- Subject: [mg57885] Re: [mg57860] "expanding a list"
- From: "Tomas Garza" <tgarza10 at msn.com>
- Date: Sat, 11 Jun 2005 03:35:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Perhaps this will work:
In[1]:=
xes={x1,x2,x3,x4,x5,x6,x7,x8,x9,x10};
In[2]:=
nums={5,3};
In[3]:=
expandedList=
Prepend[Table[xes[[j]],{j,2,Length[xes]},{nums[[2]]}],
Table[xes[[1]],{nums[[1]]}]]
Out[3]=
{{x1,x1,x1,x1,x1},{x2,x2,x2},{x3,x3,x3},{x4,x4,x4},{x5,x5,x5},{x6,x6,x6},{x7,
x7,x7},{x8,x8,x8},{x9,x9,x9},{x10,x10,x10}}
Tomas Garza
Mexico City
>From: Mark Coleman <mark at markscoleman.com>
To: mathgroup at smc.vnet.net
>Subject: [mg57885] [mg57860] "expanding a list"
>Date: Fri, 10 Jun 2005 02:29:26 -0400 (EDT)
>
>Greetings,
>
>I'd like to construct a list as follows. Say I have a list of reals
>{x1,x2,x3,...xn}, and another list of integers {r,s}. I'd like to
>make a new list
>
>{{x1,x1,x1,...},{x2,x2,x2....},{x3,x3,x3,...},....,{xn,xn,xn,...}},
>where the first sublist is of length r, and the remaining sublists
>are of length s.
>
>
>Thanks,
>
>-Mark
>
>
>