Averages/Root mean square: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 527: | Line 527: | ||
→ 6.2048368229954285 |
→ 6.2048368229954285 |
||
</lang> |
</lang> |
||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
Line 646: | Line 647: | ||
Answer (in F# Interactive window): |
Answer (in F# Interactive window): |
||
<pre>val res : float = 6.204836823</pre> |
<pre>val res : float = 6.204836823</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Fantom}}== |
=={{header|Fantom}}== |
||
Line 664: | Line 672: | ||
} |
} |
||
}</lang> |
}</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Line 898: | Line 899: | ||
| if $length == 0 then null |
| if $length == 0 then null |
||
else map(. * .) | add | sqrt / $length |
else map(. * .) | add | sqrt / $length |
||
end ;</lang>With this definition, the following program would compute the rms of each array in a file or stream of numeric arrays:<lang jq>rms</lang> |
end ;</lang>With this definition, the following program would compute the rms of each array in a file or stream of numeric arrays:<lang jq>rms</lang> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
There are a variety of ways to do this via built-in functions in Julia, given an array <code>A = [1:10]</code> of values. The formula can be implemented directly as: |
There are a variety of ways to do this via built-in functions in Julia, given an array <code>A = [1:10]</code> of values. The formula can be implemented directly as: |
||
Line 1,024: | Line 1,026: | ||
rms(L), numer; /* 6.204836822995429 */</lang> |
rms(L), numer; /* 6.204836822995429 */</lang> |
||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
<lang MAXScript> |
<lang MAXScript> |
||
Line 1,156: | Line 1,159: | ||
Quadratic Mean: 6.20483682300 |
Quadratic Mean: 6.20483682300 |
||
</pre> |
</pre> |
||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
<lang objeck>bundle Default { |
<lang objeck>bundle Default { |
||
Line 1,270: | Line 1,274: | ||
say rms(1..10);</lang> |
say rms(1..10);</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,485: | Line 1,480: | ||
(sqrt (/ (for/sum ([n nums]) (* n n)) (length nums)))) |
(sqrt (/ (for/sum ([n nums]) (* n n)) (length nums)))) |
||
</lang> |
</lang> |
||
⚫ | |||
(formerly Perl 6) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 1,581: | Line 1,586: | ||
{{out}} |
{{out}} |
||
The root mean square is: 6.204837 |
The root mean square is: 6.204837 |
||
=={{header|S-lang}}== |
=={{header|S-lang}}== |
||
Line 1,653: | Line 1,657: | ||
writeln(rms(numbers) digits 7); |
writeln(rms(numbers) digits 7); |
||
end func;</lang> |
end func;</lang> |
||
=={{header|Shen}}== |
=={{header|Shen}}== |
||
{{works with|shen-scheme|0.17}} |
{{works with|shen-scheme|0.17}} |
||
Line 1,820: | Line 1,825: | ||
6.2048368229954285 |
6.2048368229954285 |
||
</pre> |
</pre> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |