Skip to content

Instantly share code, notes, and snippets.

@ehamberg
Created August 19, 2011 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ehamberg/1156601 to your computer and use it in GitHub Desktop.
Save ehamberg/1156601 to your computer and use it in GitHub Desktop.
import qualified Data.HashMap.Lazy as M -- from unordered-containers
firstNonRep :: String -> Char
firstNonRep =
head . M.keys . M.filter (==1) . M.fromListWith (+) . map (\c -> (c,1))
main = print $ firstNonRep "aabcbcdeef" == 'd'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment