Skip to content

Instantly share code, notes, and snippets.

@akira02
Created April 26, 2018 16:52
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 akira02/1ae4c0cce5d3941bce00813fcca4bbd1 to your computer and use it in GitHub Desktop.
Save akira02/1ae4c0cce5d3941bce00813fcca4bbd1 to your computer and use it in GitHub Desktop.
Implement nub function in Haskell
import qualified Data.Set as S
nub = go S.empty
where go _ [] = []
go s (x:xs) | S.member x s = go s xs
| otherwise = x : go (S.insert x s) xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment