Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,20 +1,19 @@
import std.stdio;
T[] forwardDifference(T)(in T[] data, in int level) pure nothrow
in {
assert(level >= 0 && level < data.length);
} body {
//auto result = data.dup; // not nothrow
auto result = data ~ []; // slower
foreach (i; 0 .. level)
foreach (j, ref el; result[0 .. $ - i - 1])
el = result[j + 1] - el;
result.length -= level;
return result;
}
in {
assert(level >= 0 && level < data.length);
} body {
auto result = data.dup;
foreach (immutable i; 0 .. level)
foreach (immutable j, ref el; result[0 .. $ - i - 1])
el = result[j + 1] - el;
result.length -= level;
return result;
}
void main() {
auto data = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
foreach (level; 0 .. data.length)
writeln(forwardDifference(data, level));
import std.stdio;
const data = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
foreach (immutable level; 0 .. data.length)
forwardDifference(data, level).writeln;
}