langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,4 @@
|
|||
fun mean_reals [] = 0.0
|
||||
| mean_reals xs = foldl op+ 0.0 xs / real (length xs);
|
||||
|
||||
val mean_ints = mean_reals o (map real);
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
fun mean_reals [] = raise Empty
|
||||
| mean_reals xs = let
|
||||
val (total, length) =
|
||||
foldl
|
||||
(fn (x, (tot,len)) => (x + tot, len + 1.0))
|
||||
(0.0, 0.0) xs
|
||||
in
|
||||
(total / length)
|
||||
end;
|
||||
|
||||
|
||||
fun mean_ints [] = raise Empty
|
||||
| mean_ints xs = let
|
||||
val (total, length) =
|
||||
foldl
|
||||
(fn (x, (tot,len)) => (x + tot, len + 1.0))
|
||||
(0, 0.0) xs
|
||||
in
|
||||
(real total / length)
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue