langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -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);

View file

@ -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;