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

Hugo Mills hugo@REDACTED
Mon Feb 20 16:21:18 CET 2017


On Mon, Feb 20, 2017 at 03:32:56PM +0100, lenartlad@REDACTED wrote:
> Hello.
> 
> What about this:
> 
> sets:size(S1) == sets:size(S2) andalso sets:is_subset(S1, S2)
> 
> ?
> 
> This seems rather elegant, at least to me :-)

   It was my fallback solution, too.

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

1> sets:is_subset(sets:new(), sets:new()).
true

so that edge case works, too.

   Hugo.

> HTH,
> 
> Ladislav Lenart
> 
> 
> ______________________________________________________________
> > Od: "Alex S." <alex0player@REDACTED>
> > Komu: Hugo Mills <hugo@REDACTED>
> > Datum: 20.02.2017 15:11
> > Předmět: Re: [erlang-questions] Bug in sets module? Equal sets aren't equal
> >
> > CC: <erlang-questions@REDACTED>
> >
> >> 20 февр. 2017 г., в 16:58, Hugo Mills <hugo@REDACTED> написал(а):
> >> 
> >> 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
> >erlang-questions@REDACTED
> >http://erlang.org/mailman/listinfo/erlang-questions
> >
> >

-- 
Hugo Mills             | Great films about cricket: Umpire of the Rising Sun
hugo@REDACTED 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/2945acea/attachment.bin>


More information about the erlang-questions mailing list