Skip to main content
added 10 characters in body; edited title
Source Link
user64494
  • 29.1k
  • 4
  • 29
  • 56

How to efficiently Append a result of an operation on each element of a list to itself?

How to efficiently Append a result of an operation on each element of a list to itself?

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

How to efficiently Append a result of an operation on each element of a list to itself

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

How to efficiently Append a result of an operation on each element of a list to itself?

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

Commonmark migration
Source Link

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

###Example:

Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

###Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

I gave myself freedom to change the code so it is now readable. Variable names does not matter.
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

###Example:

(*INPUT*Input:*)
 {{ExperimentCode1x1, No of Experiments1y1, 
  Volume Used1z1}, {ExperimentCode2x2, No of Experiments2y2, Volume Used2z2}, ...}  

(*OUTPUT:*)
 {{ExperimentCode1, No of Experiments1,
   Volume Used1, (No of Exp1 * Vol Used1)}, {ExperimentCode, 
    No of Experiments, Volume Used, (No of Exp2*Desired output:* Vol Used2)} ...}  
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with 'AppendTo'AppendTo, but I guess there is a faster method.

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

###Example:

(*INPUT:*)
 {{ExperimentCode1, No of Experiments1, 
  Volume Used1}, {ExperimentCode2, No of Experiments2, Volume Used2} ...}  

(*OUTPUT:*)
 {{ExperimentCode1, No of Experiments1,
   Volume Used1, (No of Exp1 * Vol Used1)}, {ExperimentCode, 
    No of Experiments, Volume Used, (No of Exp2 * Vol Used2)} ...}  

I know I could just use a Do loop with an index k and do it element by element with 'AppendTo', but I guess there is a faster method.

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:

###Example:

(*Input:*)
 {{x1, y1, z1}, {x2, y2, z2}, ...}  

(*Desired output:*)
{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...}  

I know I could just use a Do loop with an index k and do it element by element with AppendTo, but I guess there is a faster method.

Tweeted twitter.com/#!/StackMma/status/177363806597545984
edited title
Link
rm -rf
  • 89.3k
  • 21
  • 296
  • 478
Loading
added 41 characters in body; edited tags; edited title
Source Link
rm -rf
  • 89.3k
  • 21
  • 296
  • 478
Loading
edited body
Source Link
Loading
Source Link
Loading