Averages/Root mean square: Difference between revisions

m
m (→‎{{header|Phix}}: changed my mind and split the one-liner, and explained why)
Line 1,343:
</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. The last (commented-out) line also removes the function call, but of course it has also removed every last descriptive hint of what it is supposed to be doing as well.
<lang Phix>function rms(sequence s)
atom sqsum = sum(apply(true,power,{s,2}))
return sqrt(sqsum/length(s))
end function
?rms(tagset(10))</lang>
-- ?sqrt(sum(apply(true,power,{tagset(10),2}))/10) -- (ugh)</lang>
 
=={{header|Phixmonti}}==
7,804

edits