Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
No edit summary |
(added Ursala) |
||
Line 751: | Line 751: | ||
<lang bash>(echo 3; echo 1; echo 4) | mean</lang> |
<lang bash>(echo 3; echo 1; echo 4) | mean</lang> |
||
=={{header|Ursala}}== |
|||
There is a library function for means already, although it doesn't cope with |
|||
empty vectors. A mean function could be defined as shown for this task. |
|||
<lang Ursala>#import nat |
|||
#import flo |
|||
mean = ~&?\0.! div^/plus:-0. float+ length |
|||
#cast %e |
|||
example = mean <5.,3.,-2.,6.,-4.></lang> |
|||
output: |
|||
<pre>1.600000e+00</pre> |
|||
=={{header|V}}== |
=={{header|V}}== |