Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created December 24, 2014 00:16
Show Gist options
  • Save jarsen/267e12246c01b4523652 to your computer and use it in GitHub Desktop.
Save jarsen/267e12246c01b4523652 to your computer and use it in GitHub Desktop.
haskell reverseInt implementation
reverseInt :: (Integral a) => a -> a
reverseInt x = reverseInt' x 0
reverseInt' :: (Integral a) => a -> a -> a
reverseInt' n r
| n == 0 = r
| otherwise = reverseInt' (quot n 10) (10 * r + n `mod` 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment