```
import std.algorithm : map, until;
import std.range : iota;
import std.array : array;
int access;
int logAccess(int x) {
access++;
return x;
}
void main()
{
iota(10).map!logAccess.until(10).array;
assert(access == 20);
}
```
if you remove the `.until(10)`, you get `access == 10`
Comment #1 by d.bugs — 2023-09-20T01:46:17Z
`std.algorithm:cache` could be used, but that still evalutes .front one time too many compared to when `until` should stop when No.openRight is passed in as argument, e.g.
```
iota(10).map!logAccess.cache.until(5, No.openRight).array;
```
will call logAccess on 0, 1, 2, 3, 4, 5 and 6
Comment #2 by robert.schadek — 2024-12-01T16:41:49Z