Partial function application: Difference between revisions
Content deleted Content added
Updated D version |
|||
Line 248:
<lang d>import std.stdio, std.algorithm, std.traits;
auto fs(alias f)(in int[] s) /*pure nothrow*/
if (isCallable!f && ParameterTypeTuple!f.length == 1) {
return map!f(s);
}
int f1(in int x) pure nothrow { return x * 2; }
int f2(in int x) pure nothrow { return x
alias fs!f1 fsf1;
Line 260:
void main() {
writeln(fsf1(
writeln(fsf2(
}
}</lang>
Output:
|