Skip to main content
added 268 characters in body
Source Link
LLlAMnYP
  • 11.5k
  • 27
  • 66

My take (but the fractions in the third element are always converted from a/(b/c) to ac/b, such is life).

transform = 
 {Total@#1[[1 ;; -2, 1]],
  Sqrt[Total@(#1[[1 ;; -2, 2]]^2)], 
  #1[[-1, 3]]/((#1[[1 ;; -2, 1]]).(#1[[1 ;; -2, 3]])/Total@#1[[1 ;; -2, 1]])
 } & 

transform[list[[1;;#]]]&/@Range[2,Length@list]

Alternatively, because First, Rest, Most, and Last are better than Part:

transform = 
  {Total@(First /@ Most@#),
   Sqrt[Total@(Most@#^2)][[2]], 
   Last@Last@#/((First /@ Most@#).(Last /@ Most@#)/Total@(First /@ Most@#))
  } & 

My take (but the fractions in the third element are always converted from a/(b/c) to ac/b, such is life).

transform = 
 {Total@#1[[1 ;; -2, 1]],
  Sqrt[Total@(#1[[1 ;; -2, 2]]^2)], 
  #1[[-1, 3]]/((#1[[1 ;; -2, 1]]).(#1[[1 ;; -2, 3]])/Total@#1[[1 ;; -2, 1]])
 } & 

transform[list[[1;;#]]]&/@Range[2,Length@list]

My take (but the fractions in the third element are always converted from a/(b/c) to ac/b, such is life).

transform = 
 {Total@#1[[1 ;; -2, 1]],
  Sqrt[Total@(#1[[1 ;; -2, 2]]^2)], 
  #1[[-1, 3]]/((#1[[1 ;; -2, 1]]).(#1[[1 ;; -2, 3]])/Total@#1[[1 ;; -2, 1]])
 } & 

transform[list[[1;;#]]]&/@Range[2,Length@list]

Alternatively, because First, Rest, Most, and Last are better than Part:

transform = 
  {Total@(First /@ Most@#),
   Sqrt[Total@(Most@#^2)][[2]], 
   Last@Last@#/((First /@ Most@#).(Last /@ Most@#)/Total@(First /@ Most@#))
  } & 
Source Link
LLlAMnYP
  • 11.5k
  • 27
  • 66

My take (but the fractions in the third element are always converted from a/(b/c) to ac/b, such is life).

transform = 
 {Total@#1[[1 ;; -2, 1]],
  Sqrt[Total@(#1[[1 ;; -2, 2]]^2)], 
  #1[[-1, 3]]/((#1[[1 ;; -2, 1]]).(#1[[1 ;; -2, 3]])/Total@#1[[1 ;; -2, 1]])
 } & 

transform[list[[1;;#]]]&/@Range[2,Length@list]