Casting MapResult

Baz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 15 15:40:30 PDT 2015


On Monday, 15 June 2015 at 20:10:30 UTC, jmh530 wrote:
>> I suppose I would want whichever has the best performance. 
>> Without testing, I'm not sure which one would be better. 
>> Thoughts?
>>
>> I had been fighting with the map results because I didn't 
>> realize there was an easy way to get just the array.
>
> I'm actually not having much luck with your original function 
> (and I tried some variations on it). It just kept outputting 
> the original array without applying the function. I tried it in 
> main also (without being in a function) without much luck 
> either.

Right, my bad. This one whould work:

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


More information about the Digitalmars-d-learn mailing list