[Haskell-cafe] lexicographic order
chaddai.fouche at gmail.com
Sun Mar 30 18:48:50 EDT 2008
2008/3/30, Bulat Ziganshin <bulat.ziganshin at gmail.com>:
> although the last alternative,
> (Branch l r) <= (Branch l' r') = l == l' && r <= r' || l <= l'
> seems suspicious to me. isn't it the same as
> (Branch l r) <= (Branch l' r') = l <= l'
Yes, it should be :
(Branch l r) <= (Branch l' r') = l < l' || l == l' && r <= r'
Lexical order for a tuple (a,b) is :
(a,b) <= (a',b') iff (a < a' or (a == a' and b <= b'))
The same idea can be applied to list (where Nil is strictly less than
anything else) or other datatypes.
More information about the Haskell-Cafe