Skip to content

Instantly share code, notes, and snippets.

@damonvjanis
Last active December 5, 2018 21:35
Show Gist options
  • Save damonvjanis/ae89bf2d0065fb1b3252d1f963ef26f1 to your computer and use it in GitHub Desktop.
Save damonvjanis/ae89bf2d0065fb1b3252d1f963ef26f1 to your computer and use it in GitHub Desktop.
Uses maps to do a matching comparison on big datasets
contacts = Enum.group_by(contacts, fn c -> c["email"] end)
for lead <- leads do
matching_contacts = contacts[lead["email"]]
if matching_contacts do
# Return a tuple with the lead and any contacts that match
{lead, matching_contacts}
end
end
|> Enum.filter(& &1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment