Happy Happy Joy Joy (was: On to Hydro)
Tyler Close
tjclose@yahoo.com
Sat, 19 Aug 2000 15:11:41 -0400
Markm wrote:
> Believe it or not, here's a simple solution that satisfies all the
> constraints,
I think this looks good and I'll take it over what I was suggesting.
I guess a good way of characterizing the difference in the two designs
is that yours puts the burden of sussing out the properties of the
element ordering on the sort algorithm, whereas mine had the elements
declare the properties of the ordering. So long as programmers
typically use an externally provided sort algorithm, your solution
should catch usage errors. Very nice.
I have just a few miscellaneous comments on the rest.
> define pairFullSort(a, b) :any {
> define comparison := a compareTo(b)
> if (comparison atMostZero) {
> [a, b]
> } else if (comparison isNaN) {
> throw("incomparable")
> } else { # must be aboveZero
> [b, a]
> }
> }
>
> Note that this would have been a bit harder to understand
> if written with the
> relational operators.
I assume you mean relational operators not based on compareTo. If so,
is this the implementation:
define pairFullSort(a, b) : any {
if(a <= b) {
[a, b]
} else if (a > b) {
[b, a]
} else {
throw("incomparable")
}
}
> (We
> leave aside for now whether the library should be based on
> full-sorts, as
> Tyler effectively advocates, or partial-sorts, as Dean advocates.)
I was going for co-existence. I would very much like to have a Xanadu
container, but I don't have one. I do have a RedBlackTree and would
like to be able to use it.
Tyler
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com