Set Symmetric difference

78 views
Skip to first unread message

Bill Christian

unread,
Sep 2, 2014, 3:46:41 PM9/2/14
to elixir-l...@googlegroups.com
I found an old issue requesting Set Symmetric difference operation in Elixir. The issue was closed moving the conversation to Google Groups, but I am unable to find any follow through on the request. Does Elixir currently support the Set Symmentric difference operation?

As an alternative I attempted to use the Erlang Sofs library. However, :sofs.symdiff uses only sofs.Set parameter types. Is it possible for HashSet to be supported or transformed on this call? Just checking to see if I am missing how to make this call with a native Elixir type.

Onorio Catenacci

unread,
Sep 2, 2014, 4:00:00 PM9/2/14
to elixir-l...@googlegroups.com
In case I'm not the only one unclear on what Bill is referring to: https://github.com/elixir-lang/elixir/issues/1547

It looks like the note was that the discussion was moving to the _core_mailing_list.  That's not this group/mailing list.  But I looked over there too and it doesn't seem to have gone anywhere. I think this line from the PR:

"In case you want to attempt a pull request, let us know and we will be glad to help."  

Is pretty much the answer as far as whether anything happened with it or not.  It looks as if the original requester didn't care to pursue it any further. 

--
Onorio

Bill Christian

unread,
Sep 2, 2014, 4:31:01 PM9/2/14
to elixir-l...@googlegroups.com
Thanks. I should have included the link.

Alexei Sholik

unread,
Sep 3, 2014, 5:46:53 AM9/3/14
to elixir-l...@googlegroups.com
It is not difficult to implement it yourself. Unless you have a clever algorithm in mind that applies specifically to, say, HashSet, using existing functions should be efficient enough.

In a casual measuring of HashSet I've found that

   sym_diff = difference(union(set1, set2), intersection(set1, set2))

performs better than

   sym_diff = union(difference(set1, set2), difference(set2, set1))


On Tue, Sep 2, 2014 at 10:46 PM, Bill Christian <bill.ch...@gmail.com> wrote:
I found an old issue requesting Set Symmetric difference operation in Elixir. The issue was closed moving the conversation to Google Groups, but I am unable to find any follow through on the request. Does Elixir currently support the Set Symmentric difference operation?

As an alternative I attempted to use the Erlang Sofs library. However, :sofs.symdiff uses only sofs.Set parameter types. Is it possible for HashSet to be supported or transformed on this call? Just checking to see if I am missing how to make this call with a native Elixir type.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best regards
Alexei Sholik

Bill Christian

unread,
Sep 3, 2014, 10:23:55 AM9/3/14
to elixir-l...@googlegroups.com
Thanks Alexei. I want to ensure I was not missing anything obvious. With my simple need, I can use your approach. Much appreciated.
Reply all
Reply to author
Forward
0 new messages