Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/Forward-difference/D/forward-difference-3.d
Normal file
12
Task/Forward-difference/D/forward-difference-3.d
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue