omnisci3nce
7/28/2017 - 12:22 AM

cis194-creditcard-toDigits.hs

toDigits :: Integer -> [Integer]
toDigits x
  | x <= 0        = []
  | divBy10 < 10 = [divBy10, remainder]
  | otherwise    = toDigits divBy10 ++ [remainder]
  where remainder = x `mod` 10
        divBy10   = x `div` 10