Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Last active May 18, 2021 14:39
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 dminuoso/3e7c5c815ce0e09a02e809d99b39e963 to your computer and use it in GitHub Desktop.
Save dminuoso/3e7c5c815ce0e09a02e809d99b39e963 to your computer and use it in GitHub Desktop.
isUnique xs = go Set.empty xs
where
go buf (x:xs) = x `Set.notMember` buf -- if we have seen it before, we break off
&& go (Set.insert x buf) xs -- otherwise, put the element to the set, move on to the rest
go _ [] = True -- list is unique if we reached the end of it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment