정말, 이렇게까지?
oddDigits :: Integer -> Int
oddDigits = go 0
where
go :: Int -> Integer -> Int
go s 0 = s
go s n = s `seq` go (s + fromInteger r `mod` 2) q
where (q, r) = n `quotRem` 10
https://stackoverflow.com/questions/59824578/count-number-of-odd-digits-in-integer-haskell
댓글 없음:
댓글 쓰기