Skip to content

Instantly share code, notes, and snippets.

@taiansu
Last active May 12, 2018 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiansu/3c041a7b972701c4154e651b4bcc4693 to your computer and use it in GitHub Desktop.
Save taiansu/3c041a7b972701c4154e651b4bcc4693 to your computer and use it in GitHub Desktop.
Flolac week of code 1: nub
nub' :: [Int] -> [Int]
nub' = foldr f [] where
f x xs
| x `elem` xs = xs
| otherwise = x:xs
-- without using `elem`
nub'' :: [Int] -> [Int]
nub'' = foldr f [] where
f x xs
| length (filter (x ==) xs) > 0 = xs
| otherwise = x:xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment