Re: "expanding a list"
- To: mathgroup at smc.vnet.net
- Subject: [mg57873] Re: "expanding a list"
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Sat, 11 Jun 2005 03:35:27 -0400 (EDT)
- Organization: Uni Leipzig
- References: <d8bd00$fj0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, ExpandList[lst_List, {a_, b_}] := ExpandList[lst, Prepend[Table[b, {Length[lst] - 1}], a]] ExpandList[lst_List, rep_List] /; Length[lst] == Length[rep] := MapThread[Table, {lst, {#} & /@ rep}] ?? Regards Jens "Mark Coleman" <mark at markscoleman.com> schrieb im Newsbeitrag news:d8bd00$fj0$1 at smc.vnet.net... > 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 > > >