[erlang-questions] Bug in sets module? Equal sets aren't equal

Hugo Mills <>
Mon Feb 20 15:16:16 CET 2017


On Mon, Feb 20, 2017 at 05:11:25PM +0300, Alex S. wrote:
> 
> > 20 февр. 2017 г., в 16:58, Hugo Mills <> написал(а):
> > 
> > sets:from_list([[2, 2], [2, -2]]) =:= sets:from_list([[2, -2], [2, 2]]).
> 
> The onyl way to compare them for equality would be elementwise anyway, i.e. I'd roll with sets:to_list, it’s about as optimal as it gets.

   No, that's not going to work:

1> sets:to_list(sets:from_list([[2, 2], [2, -2]])).
[[2,2],[2,-2]]
2> sets:to_list(sets:from_list([[2, -2], [2, 2]])).
[[2,-2],[2,2]]

   It looks like the best you can do is this:

sets:size(A) =:= sets:size(B) and sets:is_subset(A, B).

   Hugo.

-- 
Hugo Mills             | Great films about cricket: Umpire of the Rising Sun
 carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170220/9b384254/attachment.bin>


More information about the erlang-questions mailing list