I want to make a program that returns true if a string contains only digits in Haskell.
This is my attempt:
checkNum :: String -> Bool
checkNum xs = ((length (filter isDigit xs )) == length (xs))
This is the error I get:
Not in scope: `isDigit'
What's wrong with my code?
This should work:
import Data.Char (isDigit)
checkNum :: String -> Bool
checkNum = all isDigit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With