RosettaCodeData/Task/Symmetric-difference/Elixir/symmetric-difference.elixir

9 lines
372 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
iex(1)> a = ~w[John Bob Mary Serena] |> MapSet.new
#MapSet<["Bob", "John", "Mary", "Serena"]>
iex(2)> b = ~w[Jim Mary John Bob] |> MapSet.new
#MapSet<["Bob", "Jim", "John", "Mary"]>
iex(3)> sym_dif = fn(a,b) -> MapSet.difference(MapSet.union(a,b), MapSet.intersection(a,b)) end
#Function<12.54118792/2 in :erl_eval.expr/5>
2015-11-18 06:14:39 +00:00
iex(4)> sym_dif.(a,b)
2016-12-05 22:15:40 +01:00
#MapSet<["Jim", "Serena"]>