News for hackers. Stuff that matters.
Re:The Evil Within the Comparison Functions by thaumasiotes on Monday February 19, 2018 @04:38AM (#16411810)
> Something I'd like people to consider is simply taking the middle value.

> This supports any crazy rationale you might have for a particular order, and it is resistant to a lot of bugs you're likely to make since the code isn't particularly repetitive no matter what language you use. Oh and it doesn't have any comparison operators either.

Most of your examples seem to call a "sort" function. Are you sure you're not using any comparisons?

Re:The Evil Within the Comparison Functions by geocar on Monday February 19, 2018 @06:36AM (#16412266)
The thing to focus on in the mental load. What are you more likely to get right?

    a = sort(x,y,z); return a[1]
or something like this?

    if(x >= y && x =< z) return x;
    if(y >= x && y =< z) return y;
    if(z >= x && z =< y) return z;
    if(x >= z && x =< y) return x;
    if(y >= z && y =< x) return y;
    if(z >= y && z =< x) return z;
    …
Re:The Evil Within the Comparison Functions by thaumasiotes on Monday February 19, 2018 @03:09PM (#16415321)

    return max(low, ( min(val, high) ));
Still hard to avoid comparisons.