On 12/29/13 2:20 AM, monarch_dodra wrote:
There is precedence for this in phobos with schwatzSort: It use a
unaryFun, followed by a binaryFun.

I've found this works quite well: More often than not, a unary fun is
more than enough (the default "a < b"/"a == b" is fine). And in the
cases where you *do* need binary comparison, then having a unary fun
anywas is fine. EG:

"MHklfsJKGsfd".byGroup!(std.uni.tolower, "a < b")();

I think it is both an elegant and efficient approach. That's what I'd go
for.

Hm so that's different from both my suggestions. It's also more difficult to explain, though indeed there's precedent with schwartz.

I think we should handle non-commutative predicates. It's not actually
*that* much more complicated. Instead of storing in each Group a value +
range, simply save the range twice, and have one range be 1 step ahead
of the first. I think a few phobos algos do this. minPos does something
kind of similar.

The existing pull request already supports non-commutative predicates by means of copying the front. I'd thought about using the step-behind-range trick but that's less efficient than a copy in many cases. It's more general though as you point out, so I'll probably switch to that.


Andrei

Reply via email to