On Monday, 15 June 2015 at 22:40:31 UTC, Baz wrote:

Right, my bad. This one whould work:

---
float[] test(float[] x) {
    auto result = x.dup;
    result.each!((ref a) => (a = exp(a)));
    return result;
}
---

That works. Thanks.

I did some benchmarking and found that map tended to be faster than each. For some large arrays, it was exceptionally faster. Perhaps it has to do with the extra copying in the each formula?

I also did an alternative to each using foreach and they were exactly the same speed.

Reply via email to