[Haskell-cafe] lexicographic order

Simeon Mattes simeon.mattes at gmail.com
Mon Mar 31 02:10:07 EDT 2008



Chaddaï Fouché-2 wrote:
> 
> 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.
> 
> -- 
> Jedaï
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 



Chaddaï Fouché-2 wrote:
> 
> 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.
> 
> -- 
> Jedaï
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
Quoted from: 
http://www.nabble.com/lexicographic-order-tp16381434p16388762.html


Thanks for your help...I feel so embarrassed. With all of these symbolos in
Haskell like -> (for types), => (in classes) etc I couldn't imagine that <=
means less than or equal to!!!:clap:

>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'))

I have tested it and I have found that it is the same with
(Branch l r) <= (Branch l' r')  =  (l == l' && r <= r') || l < l'

The problem with the previous is that the compiler during the parsing takes
as right
(Branch l r) <= (Branch l' r')  =  l == l' && (r <= r') || l < l')
since the infix operator && needs two operands,i.e. one on the left and the
other on the right


Though I can't understand why both
(Branch l r) <= (Branch l' r')  =  l < l' || l == l' && r <= r'
(Branch l r) <= (Branch l' r')  =  l <= l' || l == l' && r <= r'

give the same results and why I should take as right 
(a,b) <= (a',b') iff (a < a' or (a == a' and b <= b'))
and not
(a,b) <= (a',b') iff (a <= a' or (a == a' and b <= b'))

The latter seems more logical, doesn't it?


-- 
View this message in context: http://www.nabble.com/lexicographic-order-tp16381434p16392557.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list