Casting MapResult
jmh530 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 15 12:44:55 PDT 2015
On Monday, 15 June 2015 at 19:32:12 UTC, Baz wrote:
> On Monday, 15 June 2015 at 19:30:08 UTC, Baz wrote:
>> On Monday, 15 June 2015 at 19:22:31 UTC, jmh530 wrote:
>>> On Monday, 15 June 2015 at 19:04:32 UTC, Baz wrote:
>>>> In addition to the other answers you can use
>>>> std.algorithm.iteration.each():
>>>>
>>>> ---
>>>> float[] _exp(float[] x) {
>>>> auto result = x.dup;
>>>> result.each!(a => exp(a));
>>>> return result;
>>>> }
>>>> ---
>>>
>>> Am I right that the difference is that map is lazy and each
>>> is greedy? Does that have any significant performance effects?
>>
>> i think that the OP wants greedy. That's why he had to fight
>> with map results.
>
> Ah sorry it's you the OP. just get it. So you wanted greedy,
> didn't you ?
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.
More information about the Digitalmars-d-learn
mailing list