Averages/Root mean square: Difference between revisions

m
→‎{{header|Phix}}: changed my mind and split the one-liner, and explained why
m (→‎{{header|Phix}}: added shorter alternative)
m (→‎{{header|Phix}}: changed my mind and split the one-liner, and explained why)
Line 1,342:
6.204836823
</pre>
Alternative, same output<br>
You could make this a one-liner, for no gain and making it harder to debug - an explicitly named intermediate such as sqsum adds no additional overhead compared to the un-named hidden temporary variable the compiler would otherwise use anyway, and of course sqsum can be examined/verified to pinpoint any error more effectively.
<lang Phix>function rms(sequence s)
returnatom sqsum = sqrt(sum(apply(true,power,{s,2}))/length(s))
return sqrt(sqsum/length(s))
end function
?rms(tagset(10))</lang>
7,820

edits