Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created December 24, 2014 00:15
Show Gist options
  • Save jarsen/9dc6fa74009238a33099 to your computer and use it in GitHub Desktop.
Save jarsen/9dc6fa74009238a33099 to your computer and use it in GitHub Desktop.
haskell itoa implementation
itoa :: (Integral a) => a -> String
itoa x
| x == 0 = "0"
| x == 1 = "1"
| x == 2 = "2"
| x == 3 = "3"
| x == 4 = "4"
| x == 5 = "5"
| x == 6 = "6"
| x == 7 = "7"
| x == 8 = "8"
| x == 9 = "9"
| x < 0 = "-" ++ itoa (abs x)
| x > 0 = itoa (quot x 10) ++ itoa (x `mod` 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment