Skip to content

Instantly share code, notes, and snippets.

@edgerunner
Last active October 17, 2019 11:19
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 edgerunner/5952e80810e6928f2a53f71a55648feb to your computer and use it in GitHub Desktop.
Save edgerunner/5952e80810e6928f2a53f71a55648feb to your computer and use it in GitHub Desktop.
Spelling book generator
speller :: [[Char]] -> [Char]
speller list =
spell (filter ((/=) "") list)
spell :: [[Char]] -> [Char]
spell [] = []
spell [single] =
isFor single
spell [first, second] =
isFor first ++ " and " ++ isFor second
spell (first:rest) =
isFor first ++ ", " ++ spell rest
isFor :: [Char] -> [Char]
isFor [single] =
single : " is just " ++ [single]
isFor (first:rest) =
first : " is for " ++ (first:rest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment