[Issue 18975] New: permutations.array creates an array of the original type without the permutations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 12 15:26:39 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18975

          Issue ID: 18975
           Summary: permutations.array creates an array of the original
                    type without the permutations
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: someone_i_dont_know at outlook.com

Weird title, but the problem is that using
permutations.some_lazy_range_algorithm.array returns an array of the original
elements, without the permutations. See code :

--- bug.d
void main()
{
    import std.algorithm : permutations;
    import std.stdio : writeln;
    import std.array : array;

    [1, 2, 3].permutations.writeln;
//prints : [[1, 2, 3], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [3, 2, 1]]

    [1, 2, 3].permutations.array.writeln;
//prints : [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]
}
---

bug seems to affect all versions from 2.69 onwards, per run.dlang.io :
https://run.dlang.io/is/PLWWRo

--


More information about the Digitalmars-d-bugs mailing list