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

@ -3,7 +3,7 @@ import std.stdio, std.typetuple, std.traits;
T[][] elementwise(string op, T, U)(in T[][] A, in U B)
@safe pure nothrow
if (isNumeric!U || (isArray!U && isArray!(ForeachType!U) &&
isNumeric!(ForeachType!(ForeachType!U)))) {
isNumeric!(ForeachType!(ForeachType!U)))) {
static if (!isNumeric!U)
assert(A.length == B.length);
if (!A.length)
@ -22,13 +22,13 @@ if (isNumeric!U || (isArray!U && isArray!(ForeachType!U) &&
}
void main() {
/*immutable*/ const matrix = [[3, 5, 7],
[1, 2, 3],
[2, 4, 6]];
enum scalar = 2;
enum matFormat = "[%([%(%d, %)],\n %)]]\n";
immutable matrix = [[3, 5, 7],
[1, 2, 3],
[2, 4, 6]];
foreach (op; TypeTuple!("+", "-", "*", "/", "^^")) {
foreach (immutable op; TypeTuple!("+", "-", "*", "/", "^^")) {
writeln(op, ":");
writefln(matFormat, elementwise!op(matrix, scalar));
writefln(matFormat, elementwise!op(matrix, matrix));