.array required if FilterResult is fed to parallel [lazy]

kdevel kdevel at vogtner.de
Thu Jul 3 21:56:03 UTC 2025


```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?


More information about the Digitalmars-d mailing list