[Issue 24858] maxIndex but not minIndex sometimes returns the index as an array with a single element
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 15 12:48:44 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24858
kdevel <kdevel at vogtner.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kdevel at vogtner.de
--- Comment #2 from kdevel <kdevel at vogtner.de> ---
WORKSFORME
compilable version (mi.d):
```
import std.stdio : writeln;
import std.algorithm : map;
import std.math: fabs;
import std.algorithm: minIndex, maxIndex;
unittest
{
double[] u = [-9, 3, 2, 8, 4];
writeln(u.maxIndex); // => 3, OK
writeln(u.map!fabs.minIndex); // => 2, OK
writeln(u.map!fabs.maxIndex); // => [0] ??? Expected: 0
}
```
$ dmd --version
DMD64 D Compiler v2.109.1
Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
written by Walter Bright
$ dmd -unittest -main -run mi.d
3
2
0
1 modules passed unittests
(also works under dmd 2.098, GDC 12.1, GDC 11.3)
--
More information about the Digitalmars-d-bugs
mailing list