tdlp: higher-order functions
Jerome BENOIT
g6299304p at rezozer.net
Fri Jan 20 06:32:23 PST 2012
Hello List:
In tDlp book in section 5.6 entitled `Higher-Order Functions. Function Literals,
the first code example is:
-----------------------------------------------------------------
T[] find(alias pred, T)(T[] input)
if (is(typeof(pred(input[0])) == bool)) {
for(; input.length > 0; input = input[1 .. $]) {
if (pred(input[0])) break;
}
return input;
}
-----------------------------------------------------------------
I can play it. Nevertheless, it is not clear for me right now
what is the role played by `T' in the generic argument list (alias pred, T).
(Its meaning is bypassed in this section via a `deduction' way.)
Any hint is welcome.
Thanks in advance,
Jerome
More information about the Digitalmars-d-learn
mailing list