Averages/Arithmetic mean: Difference between revisions
m
→{{header|langur}}
imported>MaD70 (→{{header|APL}}: Added proper function definition) |
Langurmonkey (talk | contribs) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 349:
3.5
</syntaxhighlight>
'''N.B.:''' the symbol for [https://aplwiki.com/wiki/Tally Tally (≢)] doesn't display correctly on Chrome-based browsers at the moment.
=={{header|AppleScript}}==
Line 1,981:
We could use fold() to write a function that takes an array and calculates the mean.
{{works with|langur|0.6.6}}▼
▲<syntaxhighlight lang="langur">val .mean = f(.x) fold(f{+}, .x) / len(.x)
writeln " custom: ", .mean([7, 3, 12])
Line 3,393 ⟶ 3,392:
=={{header|RPL}}==
This is based on the dc version above.
≪ DUP 'N' STO →LIST ΣLIST N / 'N' PURGE ≫ '<span style="color:blue">AMEAN</span>' STO
or,by using the stack instead of a temporary variable:
≪ →LIST ΣLIST LASTARG SIZE / ≫ '<span style="color:blue">AMEAN</span>' STO
CLEAR 1 2 3 5 7 DEPTH <span style="color:blue">AMEAN</span>
===Hard-working approach===
|