On a related but different topic: wouldn’t it be a good idea to have a compare function alongside the comparison operators, which would return whether the first argument is less, equal or greater than the second? Something like…
compare(X, Y) when X < Y ->
less;
compare(X, Y) when X > Y ->
greater;
compare(_X, _Y) ->
equal.
… only as a more efficient BIF. AFAICT, there is already something like that, internally.
Where could this be useful? If I look at the lists:usort/1 code for example, I see many occurences of “… is X>Y? if not, is X==Y? …”, that is, two comparisons are necessary if X=<Y. If X and Y are for example long lists which are equal or only differ in their last elements, comparisons are expensive because all elements up to the first different one are compared. And in (u)sorting, comparisons are done a lot.