map! filter! and range algorithm
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 4 12:24:02 PST 2013
On Mon, Mar 04, 2013 at 09:06:18PM +0100, Andrea Fontana wrote:
> If I understand it correctly something like:
>
> range.filter!(...).map!(...)
>
> browse range 2 times, one for filter and one for mapping doesn't it?
No, these algorithms are evaluated lazily (unless you put .array at the
end). The range is only traversed once.
> Is there a way to "parallelize" this kind of operations?
What do you mean by "parallelize"? Run in multiple threads? I don't
think you can do that, because the result of filter depends on what it
gets from map.
T
--
Skill without imagination is craftsmanship and gives us many useful
objects such as wickerwork picnic baskets. Imagination without skill
gives us modern art. -- Tom Stoppard
More information about the Digitalmars-d-learn
mailing list