Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
No edit summary |
(Arithmetic mean in Rapira) |
||
Line 3,015: | Line 3,015: | ||
<lang perl6>multi mean([]){ Failure.new('mean on empty list is not defined') }; # Failure-objects are lazy exceptions |
<lang perl6>multi mean([]){ Failure.new('mean on empty list is not defined') }; # Failure-objects are lazy exceptions |
||
multi mean (@a) { ([+] @a) / @a }</lang> |
multi mean (@a) { ([+] @a) / @a }</lang> |
||
=={{header|Rapira}}== |
|||
<lang Rapira>fun mean(arr) |
|||
sum := 0 |
|||
for N from 1 to #arr do |
|||
sum := sum + arr[N] |
|||
od |
|||
return (sum / #arr) |
|||
end</lang> |
|||
=={{header|REBOL}}== |
=={{header|REBOL}}== |