Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Created April 24, 2017 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahryarjb/7fa690913bb90ad9d56182f8869c7d16 to your computer and use it in GitHub Desktop.
Save shahryarjb/7fa690913bb90ad9d56182f8869c7d16 to your computer and use it in GitHub Desktop.
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