Re: Re: help
- To: mathgroup@smc.vnet.net
- Subject: [mg11712] Re: Re: [mg11653] help
- From: Bob Hanlon <BobHanlon@aol.com>
- Date: Thu, 26 Mar 1998 03:08:41 -0500
x = {2, 1, 3}; y = {5, 20, 1}; Here are three different ways of doing this: Flatten[(Table[#1[[1]], {#1[[2]]}] & ) /@ Transpose[{y, x}]] Flatten[MapThread[Table[#1, {#2}] & , {y, x}]] (* faster *) Flatten[Inner[Table[#1, {#2}] & , y, x, List]] (* fastest *) Bob Hanlon In a message dated 3/21/98 9:44:18 PM, you wrote: >> sorry, the first question was badly written out. >> here is the example: >> >> x = {2, 1, 3} >> y = {5, 20, 1} >> >> new vector -> {5,5, 20, 1,1,1}