Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,6 +1,4 @@
|
|||
import std.stdio;
|
||||
|
||||
real mean(Range)(Range r) {
|
||||
real mean(Range)(Range r) pure nothrow @nogc {
|
||||
real sum = 0.0;
|
||||
int count;
|
||||
|
||||
|
|
@ -16,8 +14,10 @@ real mean(Range)(Range r) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
import std.stdio;
|
||||
|
||||
int[] data;
|
||||
writeln("mean: ", data.mean());
|
||||
writeln("Mean: ", data.mean);
|
||||
data = [3, 1, 4, 1, 5, 9];
|
||||
writeln("mean: ", data.mean());
|
||||
writeln("Mean: ", data.mean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import std.stdio, std.algorithm, std.range;
|
||||
|
||||
real mean(Range)(Range r) pure nothrow {
|
||||
real mean(Range)(Range r) pure nothrow @nogc {
|
||||
return r.sum / max(1.0L, r.count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import std.stdio, std.conv, std.algorithm, std.math, std.traits;
|
||||
|
||||
CommonType!(T, real) mean(T)(T[] n ...) if (isNumeric!(T)) {
|
||||
alias CommonType!(T, real) E;
|
||||
CommonType!(T, real) mean(T)(T[] n ...) if (isNumeric!T) {
|
||||
alias E = CommonType!(T, real);
|
||||
auto num = n.dup;
|
||||
schwartzSort!(abs, "a > b")(num);
|
||||
return reduce!q{a+b}(0.0L, map!(to!E)(num)) / max(1, num.length);
|
||||
num.schwartzSort!(abs, "a > b");
|
||||
return num.map!(to!E).sum(0.0L) / max(1, num.length);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue