On Monday, 15 June 2015 at 15:10:24 UTC, jmh530 wrote:
float[] exp(float[] x) {
        auto y = x.map!(a => exp(a));
        cast(float[]) y;
        return y;
}

But I get an error that I can't convert MapResult!(__lambda2, float[]) to float[].

So I suppose I have two questions: 1) am I screwing up the cast, or is there no way to convert the MapResult to float[], 2) should I just not bother with map (I wrote an alternate, longer, version that doesn't use map but returns float[] properly).

First off: Don't cast unless you know exactly what you're doing. It's easy to stumble into undefined behaviour land with casts.

To answer the question: You can convert from from MapResult to float[], but not with a cast. Instead, use std.array.array:
    import std.array: array;
    return x.map!(std.math.exp).array;

Reply via email to