Skip to content

Instantly share code, notes, and snippets.

@hisusqristos
Created November 1, 2023 09:22
Show Gist options
  • Save hisusqristos/a45ea4bb66c1e316206887a86c25b432 to your computer and use it in GitHub Desktop.
Save hisusqristos/a45ea4bb66c1e316206887a86c25b432 to your computer and use it in GitHub Desktop.
elm remove duplicates
removeDuplicates : List a -> List a
removeDuplicates list =
case list of
[] ->
[]
first :: rest ->
if List.member first rest then
removeDuplicates rest
else
removeDuplicates rest ++ [ first ]
@hisusqristos
Copy link
Author

hisusqristos commented Nov 21, 2023

    list
        |> Set.fromList
        |> Set.toList

աղջիկ ջան

@hisusqristos
Copy link
Author

removeDuplicates : List a -> List a
removeDuplicates =
    Set.fromList >> Set.toList

աղջիկ ջան

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment