Hi, Charles,

"[EMAIL PROTECTED]" wrote:
> 
>    I think I get what you're at.  Ie, if you can compare a "which
> comes first?" on strings, why not order simply based upon left-to-
> right in pairs, treating them as if they were strings as well.
> So, 5x1 is greater than 4x9, but less than 5x2 .. yes?  Although,
> what actual use this would be, I'm not sure of.
>
>    *blinks*  What use /do/ you need (pair! > pair!) for, anyways?
> *pokes original poster* ;)  Thought exercise? :)
> 

Please see my post earlier today for more on that last issue.  To
me the question is, "Why*shouldn't* there be a built-in meaning
for comparison of *all* built-in data types?  The burden of proof
should be on the exception (in this case, not to be able to compare
ordered pairs of integers) to justify its existence as an exception."

To respond more directly to your question, we can *apply* the idea
of an ordered pair of integers to represent all kinds of things.
As soon as the decision is made to forbid ordering of pairs, we have
a limit on the convenience of making future applications of the type.
After all, taking a collection of same-type values and sorting them
is a common enough operation that it seems strange to forbit it
for ordered pairs of integers.  Ooops!  REBOL *can* sort pair data!

    >> foo: [1x1 1x2 2x1 2x2]
    == [1x1 1x2 2x1 2x2]
    >> sort foo
    == [1x1 2x1 1x2 2x2]

Given that "sort" means "put in order" it seems *very* strange to
have a data type that can be sorted but not compared, regardless of
what future uses programmers may make of that data type!  It is
certainly unaesthetic to have to define

    less-for-pairs?: func [a [pair!] b [pair!]] [
        to-logic all [a <> b   a = first sort reduce [a b]]
    ]

just to access the built-in order used by SORT (regardless of
whether that order is "intuitive" -- or not -- for any specific
application).

> 
> ****
> Dixit Allen Kamp (09.58 05.02.2002):
> > Pairs also represent size. If you only compare X then this falls
> > apart when dealing with size. Which is greater 5x1 or 3x2 ??
> 
> You miss my point. What I mean is, although there _are_ different
> ways to look at this, a simple left-to-right ordering is what is
> implemented in other cases, so...
> 
> But as I said, I'm just a Bear of Very Little Brain...
> 

Not so little, IMHO!

And, as far as the idea of using pair data to represent size, that
is clearly as much a specific application as using string data to
represent street addresses.  If one wants to use ordered pairs for
that purpose, then one can define an application-specific order
test:

    less-area?: func [a [pair!] b [pair!]] [
        (a/x * a/y) < (b/x * b/y)
    ]

    foo: [1x1 1x2 2x1 2x2]

    forall foo [
        foreach item foo [
            print [first foo item less-area? first foo item]
        ]
    ]

    1x1 1x1 false
    1x1 1x2 true
    1x1 2x1 true
    1x1 2x2 true
    1x2 1x2 false
    1x2 2x1 false
    1x2 2x2 true
    2x1 2x1 false
    2x1 2x2 true
    2x2 2x2 false

because now we're dealing with a specific interpretation of the
data type that has different implications from the notion of a
simple ordered pair of integers.

-jn-
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to