keysort + removing duplicate keys

Hans.Bolinder@REDACTED Hans.Bolinder@REDACTED
Fri Apr 28 16:16:34 CEST 2006


[Ulf Wiger:]
> At least I found this slightly surprising:
> 
> 2> lists:ukeysort(1,[{1,a},{1,b}]).
> [{1,a},{1,b}]
> 3> lists:ukeysort(1,[{1,a},{1,a}]).
> [{1,a}]
> 
> The man page says that lists:ukeysort/2 removes
> consecutive duplicates. I just assumed that it meant
> _duplicate keys_, but apparently not. 

Thanks for pointing it out.

We have decided to make an incompatible change of the functionality,
in the hope that it will be more useful.

Starting with R11B, ukeysort will remove duplicates by comparing the
keys only. The file_sorter module will be changed in a similar way
(this makes it behave more like Unix sort(1)).

For the sake of consistency, lists:usort/2 will be modified too: all
but the first of the elements comparing equal will be removed.

Best regards,

Hans Bolinder, Erlang/OTP



More information about the erlang-questions mailing list