Skip to content

Instantly share code, notes, and snippets.

@nullren
Last active November 23, 2017 21:22
Show Gist options
  • Save nullren/e58bb0da3e6c82f8969c91296ea01898 to your computer and use it in GitHub Desktop.
Save nullren/e58bb0da3e6c82f8969c91296ea01898 to your computer and use it in GitHub Desktop.
module Main (
main
)
where
import System.Environment
import Data.List
import Data.Char
wordscape rubric word = contained
where
word' = sort word
rubric' = sort rubric
contained = word' `isSubsequenceOf` rubric'
main = do
rubric <- fmap head getArgs
input <- readFile "/usr/share/dict/words"
let ls = map (map toLower) $ lines input
mapM_ putStrLn $ filter (wordscape rubric) ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment