Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,19 @@
T[] forwardDifference(T)(in T[] data, in int level) pure nothrow
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() {
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;
}

View file

@ -0,0 +1,13 @@
import std.stdio, std.algorithm, std.range, std.array;
auto forwardDifference(Range)(Range d, in int level) pure {
foreach (immutable _; 0 .. level)
d = d.zip(d.dropOne).map!(a => a[0] - a[1]).array;
return d;
}
void main() {
const data = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
foreach (immutable level; 0 .. data.length)
forwardDifference(data, level).writeln;
}

View file

@ -0,0 +1,12 @@
import std.stdio;
T[] forwardDifference(T)(T[] s, in int n) pure nothrow @nogc {
foreach (immutable i; 0 .. n)
s[0 .. $ - i - 1] = s[1 .. $ - i] - s[0 .. $ - i - 1];
return s[0 .. $ - n];
}
void main() {
immutable A = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
foreach (immutable level; 0 .. A.length)
forwardDifference(A.dup, level).writeln;
}

View file

@ -0,0 +1,10 @@
void main() {
import std.stdio, std.range;
auto D = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
writefln("%(%s\n%)",
recurrence!q{ (a[n - 1][0 .. $ - 1] =
a[n - 1][1 .. $] -
a[n - 1][0 .. $ - 1])[0 .. $] }(D)
.take(D.length));
}