Created
December 24, 2014 00:15
-
-
Save jarsen/9dc6fa74009238a33099 to your computer and use it in GitHub Desktop.
haskell itoa implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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