how to return map(fn)

steve stevethe1st at
Mon Feb 21 20:44:44 UTC 2022

following this example in the documentation of map:

import std.algorithm.comparison : equal;
import std.conv : to;

alias stringize = map!(to!string);
assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ]));

I would like to write a function that takes as its parameter a 
function and returns something like the alias in the example. 
i.e. something like:

float[] function(float[]) get_map(alias f){
    return map!(f)
I had a look at the source code for map but it seems to return a 
private struct, which doesn't help. Is there any way to get this 
to work?

More information about the Digitalmars-d-learn mailing list