On Saturday, June 15, 2013, José Valim wrote:

> In lib/elixir/lib/set.ex:
>
> > +  defp set_intersect(trie(root: root, depth: depth, size: size) = set1, set2) do
> > +    set_fold set2, ordered(), fn m, acc ->
> > +      if member?(set1, m) do
> > +        put acc, m
> > +      else
> > +        acc
> > +      end
> > +    end
> > +  end
> > +
> > +  defp set_difference(ordered(bucket: bucket1), ordered(bucket: bucket2)) do
> > +    new(bucket_difference(bucket1, bucket2))
> > +  end
> > +
> > +  defp set_difference(trie(size: size1) = set1, set2) do
> > +    set_fold set1, ordered(), fn m, acc ->
>
>  Set.difference(filled_set(20), filled_set(21)) == Set.new([]) #Fails
> This behaviour is expected. == only does structural match. And this
> behaviour will also happen in other circumstances. For example, imagine a
> hash dict (or a set) has (n - 1) items and when it reaches (n) items, it
> needs to do an expansion. If you add a new item and remove this new item
> right after, it will expand but not contract, so you have two
> dictionaries/sets, with the same amount of items, but different structures.
> That's why we need to use Dict.equal? and Set.equal? for comparison.
>
>
>
Ah makes sense, thanks for the explanation.



> —
> Reply to this email directly or view it on GitHub<https://github.com/elixir-lang/elixir/pull/1241/files#r4714707>
> .
>


-- 
--
Joseph Wilk
http://blog.josephwilk.net
@josephwilk