Skip to content

Instantly share code, notes, and snippets.

@kellyfelkins
Last active June 3, 2019 04:48
Show Gist options
  • Save kellyfelkins/6db08be6a6a01f82897f710633a7bed1 to your computer and use it in GitHub Desktop.
Save kellyfelkins/6db08be6a6a01f82897f710633a7bed1 to your computer and use it in GitHub Desktop.
find first singleton in list
def first_singleton(list) do
list
|> Enum.sort()
|> no_partner?()
end
def no_partner?([value | remaining_values]) do
if value == hd(remaining_values) do
Enum.reject(remaining_values, &(&1 == value))
|> no_partner?()
else
value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment