lists:usort bug 1

Lev Walkin vlm@REDACTED
Fri Jun 26 13:18:24 CEST 2009


Version: R13B01

Documentation:

===

        usort(Fun, List1) -> List2

               Types  Fun = fun(Elem1, Elem2) -> bool()
                       Elem1 = Elem2 = term()
                      List1 = List2 = [term()]

       Returns a list which contains the sorted elements of List1 where
       all but the  first  element  of  the  elements  comparing  equal
       according to the ordering function Fun have been deleted. Fun(A,
       B) should return true if A comes before B in the ordering, false
       otherwise.
===


Actual behavior:

18> lists:usort(fun(A, B) -> A < B end, [a, a]).
[a,a]
19> lists:usort(fun(A, B) -> A =< B end, [a, a]).
[a]
20> lists:usort(fun(A, B) -> A >= B end, [a, a]).
[a]
21> lists:usort(fun(A, B) -> A > B end, [a, a]).
[a,a]
22>

Contradicts description "should return true if A comes before B in the 
ordering, false otherwise".


-- 
Lev Walkin
vlm@REDACTED


More information about the erlang-bugs mailing list