Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created October 5, 2022 17:21
Show Gist options
  • Save dminuoso/672f3e167ddce78be6945977ce9239ba to your computer and use it in GitHub Desktop.
Save dminuoso/672f3e167ddce78be6945977ce9239ba to your computer and use it in GitHub Desktop.
import qualified Data.Set as S
myNub :: Ord a => [a] -> [a]
myNub = go S.empty
where
go seen [] = []
go seen (x:xs) | x `S.member` seen
= go seen xs
| otherwise
= x : go (S.insert x seen) xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment