Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List
- import Data.Char
- ----- predefined numlist
- numlist = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
- ----- fullWords function
- -- Using the show function to convert an Int to a String (well, show DOES eat starting zeros)
- -- Also, using div/mod combination to do this will derive incorrect anwsers for inputs longer than 10 digits
- fullWords :: Integer -> String
- fullWords n
- | n >= 0 = intercalate "-" (map (\x -> numlist!!x) $ map digitToInt (show n))
- | n < 0 = "negative-" ++ ( intercalate "-" (map (\x -> numlist!!x) $ map digitToInt (show (-n))) )
Advertisement
Add Comment
Please, Sign In to add comment