[Issue 11409] Array element-wise comparison

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 1 04:16:53 PDT 2013


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



--- Comment #4 from Iain Buclaw <ibuclaw at ubuntu.com> 2013-11-01 04:16:51 PDT ---
(In reply to comment #3)
> (In reply to comment #1)
> > Your assumption is not quite right. This is the loop comparisons goes off:
> > 
> > for (size_t u = 0; u < len; u++)
> > {
> >     int result = s1[u] - s2[u];
> >     if (result)
> >         return result;
> > }
> 
> I understand that is more or less what the loop was going off, and I am saying,
> that is inconsistent behaviour.
> It also makes no sense as a comparison, because as long as the arrays aren't
> equal, it will always only compare the first element!?
> 
> What the?
> What kind of comparison is that for a set of operations that is on 'arrays',
> not sorted data structures.

Take by way of example, how you compare two words.  You'd say that betty comes
before hello, thus "betty" < "hello" is true.

In the same logic, [0,2,0] comes before [1,1,1], thus [0,2,0] < [1,1,1].

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


More information about the Digitalmars-d-bugs mailing list