Working on a method to convert a number n into any base b and having some trouble.
Code:
int2Base :: Int -> Int -> String
int2Base n b
|n == 0 = "0"
|otherwise = (mod n b) ++ int2Base (div n b) b
and my error:
Couldn't match expected type ‘[Char]’ with actual type ‘Int’
In the second argument of ‘mod’, namely ‘b’
In the first argument of ‘(++)’, namely ‘(mod n b)’
It seems like a simply error but even when I cast it to a char it still expects '[Char]' not [Char]
(:)
). Once you've done that, you'll discover you're building your result backwards! – amalloyb <= 10
? – chepner