How to check if two lists contain overlapping elements

Notes

Want to check if two lists have overlapping elements in Elixir?

Use some set theory! 💡

  • Turn the lists into MapSets: MapSet.new(list)
  • See if the two sets are disjoint: MapSet.disjoint?/2

Want the latest Elixir Streams in your inbox?

    No spam. Unsubscribe any time.