Last active
January 23, 2017 10:55
-
-
Save maticzav/bb50da59db9cd005969098a5f206a51b to your computer and use it in GitHub Desktop.
Elm - get only one element of value from list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unique : List a -> List a | |
unique list = | |
case list of | |
[] -> | |
[] | |
x :: [] -> | |
x :: [] | |
x :: xs -> | |
if List.member x xs then | |
unique xs | |
else | |
x :: unique xs | |
-- unique [1,2,3,3,3,3] -> [1,2,3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also do it shorter