Wanted: best way to express default expectations
Dukc
ajieskola at gmail.com
Mon Oct 14 12:27:17 UTC 2019
On Saturday, 12 October 2019 at 16:48:56 UTC, Jesse Phillips
wrote:
>
> Sorry forgot the foreach break part.
>
> import std.stdio;
> void main()
> {
> import std.algorithm;
> import std.range;
>
> foreach(i; iota(10)
> .filter!(x => x%2)
> .until!(x => x>5)
> .map!"a * a"
> .filter!(x => x%4)) {
> i.writeln;
> break;
> }
> }
>
> Note this is all done lazily so there is no walking of the iota
> which happens.
This is not exactly what I wanted, but probably the best
alternative overall. At least it's better than in C#, as you
don't sacrifice as much performance for using functional
pipelines.
But I still think an `if_not`, `ifnot` or some similar keyword
would have it's place. Does anybody agree? Read: might it be
worth a DIP?
More information about the Digitalmars-d
mailing list