Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- digits :: (Integral a, Integral b) => b -> a -> [b]
- textDigits :: Text -> [Int]
- stringDigits :: String -> [Int]
- charIntMaybe :: Char -> Maybe Int
- textIntMaybe :: Integral a => Text -> Maybe a
- unDigits :: (Integral a, Integral b) => b -> [b] -> a
- intPalindrome :: (Integral a, Integral b) => b -> a -> Bool
Documentation
>>>
import Test.QuickCheck
Conversions to list of digits
Digits of a positive integer.
textDigits :: Text -> [Int] Source #
Same as stringDigits
, for Text
instead of String
.
stringDigits :: String -> [Int] Source #
Get the values of numeric characters from a string, ignoring any non-numeric characters.
>>>
stringDigits " 0 x0 42a"
[0,0,4,2]
Conversions to single digits
charIntMaybe :: Char -> Maybe Int Source #
Maps the ten numeric ascii characters to their numeric values, and all other
characters to Nothing
.
>>>
charIntMaybe '0'
Just 0
>>>
charIntMaybe '9'
Just 9
>>>
charIntMaybe 'a'
Nothing
Conversions from digits to integers
The positive integer represented by a list of digits,
Other stuff
indicates whether the base-b representation n is a
palindrome.intPalindrome
b n
>>>
intPalindrome 10 <$> [33, 13431, 21, 335]
[True,True,False,False]
Zero and one are palindromes in any base.
\(Positive n) -> intPalindrome (n+1) 0
\(Positive n) -> intPalindrome (n+1) 1