Oh yeah, unicode collation!  That's a fun time.

Floats is annoying. You should probably get a choice of invalid operation exception on nan or straight sign-magnitude interpretation (which is consistent with ieee total order). But I do concede that either way you probably want special code for it rather than keying with the isomorphism to two's-complement. That said it seems reasonable to say that floats are primitive, and layer the error check thing on top (just check first/last).

safety concerns

My response rightfully should be 'get a better compiler, then'. But I haven't had much time lately for compiler hacking so...

On Thu, 21 Dec 2023, Marshall Lochbaum wrote:

I am curious what applications there are that really need a user-specified
comparison function (rather than just a sort key, like dyadic /: takes).

There must some applications out there with some sort of smart string
ordering that couldn't be reduced to array ordering. And of course in a
language with only scalar comparison, even string ordering is a custom
comparison function.

I think the way C and Rust sort developers insist on making a generic
function to cover both numeric and arbitrary sorting is pretty silly.
Glidesort's author says it's 10-15% slower for numeric sorting because
of safety concerns that only apply to a custom comparison. And the
reason the sorting function is so hard to duplicate is because of all
the optimization for instruction-level parallelism that does nothing if
comparison is expensive...

https://news.ycombinator.com/item?id=34648947

There are some in-between cases with, say, controlling the behavior of
NaNs when sorting floats that sort of justify this setup, but I don't
think it'd be terribly hard to put together an API for float sorting if
it were actually an issue.

Marshall

On Thu, Dec 21, 2023 at 06:56:43PM -0800, Elijah Stone wrote:
> The problem it has is that if elements compare equal but don't match
> then it'll never get down to an array where ~.y has length 1.

Right, of course.  Shame on me for being lazy and not bothering to write out
*./2 u/\y.

> Modern quicksort hybrids ... always use one bit at a time.

I am curious what applications there are that really need a user-specified
comparison function (rather than just a sort key, like dyadic /: takes).


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to