module Solutions.P95 (fullWords) where
import Data.List (intercalate)
fullWords :: Integral a => a -> String
fullWords :: forall a. Integral a => a -> String
fullWords a
0 = String
"zero"
fullWords a
n = String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"-" ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ (a -> String) -> [a] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map a -> String
forall a. Integral a => a -> String
toDigit ([a] -> [String]) -> [a] -> [String]
forall a b. (a -> b) -> a -> b
$ a -> [a] -> [a]
forall a. Integral a => a -> [a] -> [a]
toList a
n []
toList :: Integral a => a -> [a] -> [a]
toList :: forall a. Integral a => a -> [a] -> [a]
toList a
0 [a]
ds = [a]
ds
toList a
n [a]
ds = a -> [a] -> [a]
forall a. Integral a => a -> [a] -> [a]
toList (a
n a -> a -> a
forall a. Integral a => a -> a -> a
`div` a
10) ((a
n a -> a -> a
forall a. Integral a => a -> a -> a
`mod` a
10) a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
ds)
toDigit :: Integral a => a -> String
toDigit :: forall a. Integral a => a -> String
toDigit a
0 = String
"zero"
toDigit a
1 = String
"one"
toDigit a
2 = String
"two"
toDigit a
3 = String
"three"
toDigit a
4 = String
"four"
toDigit a
5 = String
"five"
toDigit a
6 = String
"six"
toDigit a
7 = String
"seven"
toDigit a
8 = String
"eight"
toDigit a
9 = String
"nine"
toDigit a
_ = String
forall a. HasCallStack => a
undefined