Bug in sets module? Equal sets aren't equal

6 messages
Open this post in threaded view
|

Bug in sets module? Equal sets aren't equal

 I've just turned up this little problem: hrm@ruth:~/nightglass/software/childe\$ erl Erlang/OTP 18 [erts-7.2] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] 3> sets:from_list([[2, 2], [2, -2]]) =:= sets:from_list([[2, -2], [2, 2]]). false    Is this expected behaviour, or a bug in the sets module?    How should I compare sets for equality? There's no equality comparison function in the module. (I can see any number of solutions I could roll myself, but they're all a bit ugly).    Hugo. -- Hugo Mills             | I am an opera lover from planet Zog. Take me to your hugo@... carfax.org.uk | lieder. http://carfax.org.uk/  | PGP: E2AB1DE4          | _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions signature.asc (853 bytes) Download Attachment
Open this post in threaded view
|

Re: Bug in sets module? Equal sets aren't equal

 20 февр. 2017 г., в 16:58, Hugo Mills <[hidden email]> написал(а):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._______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions
Open this post in threaded view
|

Re: Bug in sets module? Equal sets aren't equal

 On Mon, Feb 20, 2017 at 05:11:25PM +0300, Alex S. wrote: > > > 20 февр. 2017 г., в 16:58, Hugo Mills <[hidden email]> написал(а): > > > > 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 hugo@... carfax.org.uk | http://carfax.org.uk/  | PGP: E2AB1DE4          | _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions signature.asc (853 bytes) Download Attachment
Open this post in threaded view
|

Re: Bug in sets module? Equal sets aren't equal

 In reply to this post by Hugo Mills-2 Hello. What about this: sets:size(S1) == sets:size(S2) andalso sets:is_subset(S1, S2) ? This seems rather elegant, at least to me :-) Note however that I am not sure what the function sets:is_subset/2 returns for two empty sets (I do not have Erlang available at the moment to test it). HTH, Ladislav Lenart ______________________________________________________________ > Od: "Alex S." <[hidden email]> > Komu: Hugo Mills <[hidden email]> > Datum: 20.02.2017 15:11 > Předmět: Re: [erlang-questions] Bug in sets module? Equal sets aren't equal > > CC: <[hidden email]> > >> 20 февр. 2017 г., в 16:58, Hugo Mills <[hidden email]> написал(а): >> >> 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. > >---------- > >_______________________________________________ >erlang-questions mailing list >[hidden email] >http://erlang.org/mailman/listinfo/erlang-questions> > _______________________________________________ erlang-questions mailing list [hidden email] http://erlang.org/mailman/listinfo/erlang-questions