Averages/Pythagorean means: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 3,137: | Line 3,137: | ||
</pre> |
</pre> |
||
=={{header|RPL}}== |
|||
These words can be used either on vectors or lists. |
|||
≪ → array op |
|||
≪ array 1 GET 2 array SIZE |
|||
'''IF''' DUP2 > '''THEN''' DROP2 '''ELSE FOR''' j array GET op EVAL '''NEXT END''' |
|||
≫ ≫ 'REDUCE' STO |
|||
≪ DUP ≪ + ≫ REDUCE SWAP SIZE / |
|||
≫ 'AMEAN' STO |
|||
≪ DUP ≪ * ≫ REDUCE SWAP SIZE INV ^ |
|||
≫ 'GMEAN' STO |
|||
≪ DUP ≪ INV + ≫ REDUCE INV SWAP SIZE * |
|||
≫ 'HMEAN' STO |
|||
{ 1 2 3 4 5 6 7 8 9 0 } AMEAN |
|||
{ 1 2 3 4 5 6 7 8 9 0 } GMEAN |
|||
[ 1 2 3 4 5 6 7 8 9 0 ] HMEAN |
|||
{{out}} |
|||
<pre> |
|||
3: 5.5 |
|||
2: 4.52872868812 |
|||
1: 3.41417152147 |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{works with|Ruby|1.9+}} |
{{works with|Ruby|1.9+}} |