History dependent semi_lex_compare/3

factorize/3 is already yesterday’s snow, check out naish/2.
But anything should work that doesn’t give a stack overflow.