This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -1,19 +1,19 @@
import std.stdio, std.algorithm, std.traits;
auto fs(alias f)(in int[] s) /*pure nothrow*/
auto fs(alias f)(in int[] s) pure nothrow
if (isCallable!f && ParameterTypeTuple!f.length == 1) {
return map!f(s);
return s.map!f;
}
int f1(in int x) pure nothrow { return x * 2; }
int f2(in int x) pure nothrow { return x ^^ 2; }
alias fs!f1 fsf1;
alias fs!f2 fsf2;
alias fsf1 = fs!f1;
alias fsf2 = fs!f2;
void main() {
foreach (d; [[0, 1, 2, 3], [2, 4, 6, 8]]) {
writeln(fsf1(d));
writeln(fsf2(d));
foreach (const d; [[0, 1, 2, 3], [2, 4, 6, 8]]) {
d.fsf1.writeln;
d.fsf2.writeln;
}
}