http://d.puremagic.com/issues/show_bug.cgi?id=11409

           Summary: Array element-wise comparison
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nob...@puremagic.com
        ReportedBy: daniel...@bigpond.com


--- Comment #0 from daniel...@bigpond.com 2013-11-01 02:37:19 PDT ---
void main() {
    auto a = [0, 2, 0];
    auto b = [1, 1, 1];

    // add 2 to ALL elements in C
    auto c = a.dup;
    c[] += 2;
    assert(c == [2, 4, 2]);

    // add ALL elements in B to D
    auto d = a.dup;
    d[] += b[];
    assert(d == [1, 3, 1]);

    // checks ALL elements in A are less than B
    assert(!(a < b)); // Error ...
}


As is shown above, there is an inconsistency in how array element-wise
comparisons are handled in D.
The logical conclusion (IMHO) after using the array vector operations that
mutated all elements in the lhs, is that the operation would check that the
comparison was true for (again) **ALL** elements of the arrays.

Instead, it appears to only check for the first element for which the predicate
holds true, and then stops.

This is really weird, especially when the following holds:

assert([2, 0, 0] > [1, 1, 1]); 
assert([0, 2, 0] < [1, 1, 1]); 
assert([0, 0, 2] < [1, 1, 1]); 

I couldn't find any relevant documentation on how this was supposed to work, so
these are just best guesses support with data.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to