MathGroup Archive 1998

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

Search the Archive

Re: Re: help




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}



  • Prev by Date: Re: Data Extraction from List {{x1,y1}..{xn,yn}}where , ##<x<#
  • Next by Date: Re: Re: Extracting polynomial coefficients?
  • Prev by thread: Re: help
  • Next by thread: Figure problem with Mathematica 3.0.1