New to D: parse a binary file
bearophile
bearophileHUGS at lycos.com
Sat Feb 5 12:20:39 PST 2011
spir:
> Out[] map (In, Out) (In[] source, Out delegate (In) f) {
> // (0)
...
> string hex (uint i) { return format("0x%03X", i); }
> uint[] decs = [1, 3, 9, 27, 81, 243, 729];
> auto hexes = map!(uint,string)(decs, &hex);
...
> (0) The func must be declared as delegate (instead of simple func pointer)
> because: the actual func hex beeing defined in a block, the compiler turns it
> into a delegate. Detail.
See also:
void foo(In, Out)(Out function(In) f) {}
void main() {
static int bar(int i) { return 0; }
foo(&bar);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list