Reputation: 3573
I'm trying to write dropLastDigit :: Integer -> Integer
Eg dropLastDigit 123 == 12
and dropLastDigit
with any single digit returns 0
Upvotes: 0
Views: 1077
Reputation: 60748
Just divide the number by ten.
dropLastDigit :: Integer -> Integer
dropLastDigit n = div n 10
Upvotes: 8
Reputation: 11228
dropLastDigit :: Integer -> Integer
dropLastDigit n
| (abs n) < 10 = 0
| otherwise = read $ init $ show n
Upvotes: 0