Skip to content

Instantly share code, notes, and snippets.

@rakibulislam
Created October 25, 2015 17:30
Show Gist options
  • Save rakibulislam/a2b2842f715c41a1243f to your computer and use it in GitHub Desktop.
Save rakibulislam/a2b2842f715c41a1243f to your computer and use it in GitHub Desktop.
common_items_in_two_list.erl
list1 = [1,2,3,4,5]
list2 = [2,3,6]
Set.intersection(Enum.into(list1, HashSet.new), Enum.into(list2, HashSet.new))
# => HashSet<[2, 3]>
Set.intersection(Enum.into(list1, HashSet.new), Enum.into(list2, HashSet.new)) |> Set.to_list
# => [2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment