2 ms·
To give some more examples: Tuples have a reasonable natural total order: just compare component wise. And minimum of a list of tuples makes sense. You could
by eru 7y ago
To give some more examples:
Tuples have a reasonable natural total order: just compare component wise. And minimum of a list of tuples makes sense.
You could argue that alphabetic ordering is artificial, but it's hard to argue that it ain't well established and non-surprising.
Interestingly, not all numbers have intuitive orders. Eg complex numbers don't really have a good preferred ordering. And the ordering of p-adic numbers is well defined and unique, but really weird.
- throwaway_pdp09 7y ago> Tuples have a reasonable natural total order No they don't. (1, 2) > (2, 1) = ??? To compare tuples you need a generalisation of comparison which includes 'incomparable' as an outcome. See lattices https://en.wikipedia.org/wiki/Lattice_%28order%29 https://en.wikipedia.org/wiki/Lattice_%28order%29 > but it's hard to argue that [alphabetic ordering] ain't well established it is, agreed... > and non-surprising ...agreed again, only because it's a convention you know so well (had it been reversed since your birth you'd say exactly the same thing). I agree with both points but that does not invalidate what I said abour alphabetic ordering being artificial.
- oefrha 7y agoThe set of tuples over a totally ordered set has a fairly natural total order as long as you accept the concept of precedence.
- throwaway_pdp09 7y agoSo evaluate (1, 2) > (2, 1) = ??? and tell me what ??? is, and why. I claim '>' is natural for 1 apple vs 2 apples, it is not natural for tuples unless you, as you say, suppose that the first in the tuple is more 'important' than the second WRT comparing. I mean I can accept that as a handy add-on, but it's not intrinsic - that's why lattices have 'incomparable', for just such a case.
- eru 7y agoOh, I think I wasn't careful enough with my language. I meant that the common ordering on tuples is reasonably natural. Not that it is necessarily the One True Natural Ordering. About lattices and partial orders: if there's a choice about what to pick as the default ordering for some built-in datatypes for your language and there are multiple reasonable choices, going with the total order seems like a good idea. To give a counterexample: functions from natural numbers to an orderable set have a well defined, reasonably natural order, just compare them like as if they were a list of elements of the orderable set. But that would be a bad idea in a programming language, and it is indeed better to just treat functions as incomparable by default.
- throwaway_pdp09 7y agoI think we can certainly agree on this. Thanks.
- int_19h 7y agoAnd Python does reflect this for complex numbers - you'll get an exception if you try to compare two for order.