whats the best way to write short ciruitable reductions?

Dennis dkorpel at gmail.com
Tue Jan 14 10:21:35 UTC 2025


On Monday, 13 January 2025 at 21:48:15 UTC, monkyyy wrote:
> Is there a clean idea someone has?

There's no state kept after each reduction step; each comparison 
is done independently of the previous ones. So this really is 
just a negated 'find' operation, for which you can use `all`:

```D
bool issorted(R)(R r) => r.slide(2).all!(a => a[0] < a[1]);
```


More information about the Digitalmars-d-learn mailing list