December 29, 2013 Re: Ultra-pure map()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | On 12/28/2013 2:07 AM, FreeSlave wrote:
> [...]
> If you want to get result just now, then use 'array' function from
> std.array module.
>
> map!fun(range).array;
>
> or
>
> array(map!fun(range));
Syntactically compact and slightly better expression of intent, but much less efficient than just calling reduce().
Dave
|
December 29, 2013 Re: Ultra-pure map()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Held | On 12/29/2013 02:11 PM, David Held wrote:> On 12/28/2013 5:13 AM, Timon Gehr wrote: >> [...] >> I wouldn't call this an 'eager map'. It's a shallow wrapper around a >> foreach loop. > > The point being that foreach loops aren't composable. Agreed. However, if they were composable they would have to be at the end of the chain because when they don't produce a range, no other function can be added after them. If we imagine a foreach that produces a range, then it becomes map. > > Dave > Ali |
December 30, 2013 Re: Ultra-pure map()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Held | On 12/29/2013 11:11 PM, David Held wrote:
> On 12/28/2013 5:13 AM, Timon Gehr wrote:
>> [...]
>> I wouldn't call this an 'eager map'. It's a shallow wrapper around a
>> foreach loop.
>
> The point being that foreach loops aren't composable.
>
> Dave
>
Wrapping it will not change that.
|
Copyright © 1999-2021 by the D Language Foundation