Sets
There is currently just one implementation of sets, the MapSet.
| iex> set1 = Enum.into 1..5, MapSet.new |
| #MapSet<[1, 2, 3, 4, 5]> |
| iex> MapSet.member? set1, 3 |
| true |
| iex> set2 = Enum.into 3..8, MapSet.new |
| #MapSet<[3, 4, 5, 6, 7, 8]> |
| iex> MapSet.union set1, set2 |
| #MapSet<[7, 6, 4, 1, 8, 2, 3, 5]> |
| iex> MapSet.difference set1, set2 |
| #MapSet<[1, 2]> |
| iex> MapSet.difference set2, set1 |
| #MapSet<[6, 7, 8]> |
| iex> MapSet.intersection set1, set2 |
| #MapSet<[3, 4, 5]> |
Get Programming Elixir 1.2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.