Created
June 12, 2021 05:48
-
-
Save moniquelive/01d09fd83922894c318e7b0d90e5cbef to your computer and use it in GitHub Desktop.
Gerador de Anagramas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import Data.List | |
ana :: String -> [String] -> [String] | |
ana word dict = let lw = length word | |
ps = (nub . permutations $ word) | |
in ps `intersect` filter (\w -> (length w) == lw) dict | |
main = do | |
putStrLn "Digite uma palavra: " | |
word <- map toLower <$> getLine | |
dict <- words . map toLower <$> readFile "/usr/share/dict/brazilian" | |
putStrLn (show . ana word $ dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment