Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -1,13 +1,10 @@
import std.stdio, std.algorithm, std.range;
auto mean(Range)(Range r) {
auto len = r.walkLength();
return len == 0 ? 0.0 : reduce!q{a + b}(0.0L, r) / len;
real mean(Range)(Range r) pure nothrow {
return reduce!q{a + b}(0.0L, r) / max(1.0L, r.count);
}
void main() {
int[] data;
writeln("mean: ", data.mean());
data = [3, 1, 4, 1, 5, 9];
writeln("mean: ", data.mean());
writeln("Mean: ", (int[]).init.mean);
writeln("Mean: ", [3, 1, 4, 1, 5, 9].mean);
}

View file

@ -1,4 +1,5 @@
#define system.
#define system'routines.
// --- Sum ---
@ -20,12 +21,12 @@
theValue += aValue.
]
#method Number = theValue / theCount.
#method number = theValue / theCount.
}
// --- Program ---
#symbol program =
[
console writeLine:(MeanAction new foreach:(1, 2, 3, 4, 5, 6, 7, 8) Number).
console writeLine:(MeanAction new foreach:(1, 2, 3, 4, 5, 6, 7, 8) number).
].