Jump to content

Averages/Arithmetic mean: Difference between revisions

added Ursala
No edit summary
(added Ursala)
Line 751:
 
<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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.