Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
iex(3)> set1 = 1..5 |>
...(3)> Enum.into(MapSet.new)
#MapSet<[1, 2, 3, 4, 5]>
iex(4)> MapSet.member? set1, 3
true
iex(5)> MapSet.member? set1, 6
false
iex(6)> set2 = 3..8 |> Enum.into(MapSet.new)
#MapSet<[3, 4, 5, 6, 7, 8]>
iex(7)> MapSet.union set1 , set2
#MapSet<[1, 2, 3, 4, 5, 6, 7, 8]>
iex(8)> MapSet.difference set1 , set2
#MapSet<[1, 2]>
iex(9)> MapSet.difference set2 , set1
#MapSet<[6, 7, 8]>
iex(10)> MapSet.intersection set2 , set1
#MapSet<[3, 4, 5]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment