.array required if FilterResult is fed to parallel [lazy]
monkyyy
crazymonkyyy at gmail.com
Thu Jul 3 22:46:53 UTC 2025
On Thursday, 3 July 2025 at 21:56:03 UTC, kdevel wrote:
> ```d
> import std;
>
> extern (C) int sleep (int);
>
> void main ()
> {
> defaultPoolThreads (8);
> auto itemsstring = "a b c d e f g";
> auto items = itemsstring
> .split // split at ws
> .filter!(s => s != "" && s[0] != '#')
> // .array // uncomment for parallel execution
> ;
> pragma (msg, typeof (items));
> foreach (item; parallel (items)) {
> sleep (1);
> writeln (item);
> }
> }
> ```
>
> This program prints the letters a to g with a 1 s pause between
> them.
> Is that intended?
likely, .array isnt aa's range code, ideally there would be a
smarter "make a forward range more random access" primitive.
More information about the Digitalmars-d
mailing list