On Friday, 22 March 2024 at 07:18:01 UTC, Alexibu wrote:
I didn't know map was lazy...
I could put .array between map and minIndex but that defeats
the purpose of ranges.
OK found the cache algorithm, that does this.
```d
import std.stdio;
import std.algorithm;
int potentiallyExpensiveCalculation(int arg)
{
writefln("eval %s",arg);
return arg;
}
int[] args = [1,2,3,-1,2];
auto best = args.map!(a =>
potentiallyExpensiveCalculation(a)).minIndex;
```
This needs n-1 compares, but is also comput
On Tuesday, 9 January 2024 at 13:22:24 UTC, bachmeier wrote:
On Tuesday, 9 January 2024 at 10:11:35 UTC, Alexibu wrote:
It looks like isInputRange is false for arrays with fixed
length by design.
I can do:
```d
float[4] arr;
foreach(x;arr)
writefln("%s",x)
```
but not :
```d
arr.each!(a =
On Tuesday, 9 January 2024 at 10:44:34 UTC, Jonathan M Davis
wrote:
How would it even be possible for a static array to be a range?
It has a fixed length. For a type to work as a range, it needs
to be possible to pop elements off of it, which you can't do
with a static array. Input ranges must
Why do I need to copy data out of memory mapped files to avoid
seg faults.
This defeats the purpose of memory mapped files.
Shouldn't the GC be able to manage it if I keep a pointer into it.
I am closing them because the OS has a limit in how many it can
open, either way the memory is still ther
On Saturday, 28 May 2022 at 14:44:56 UTC, Adam D Ruppe wrote:
On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote:
$ gdc -o ppinsta ppinsta.d parser.d
Compiling together is faster anyway this is prolly what you
want most the time.
But I know what's going on now, it is the template emissi