Non-decimal radices/Convert: Difference between revisions
→{{header|Haskell}}: (change order of functions to match order of description in preamble)
(→{{header|Haskell}}: (change order of functions to match order of description in preamble)) |
|||
Line 1,273:
<lang haskell>import Data.List (unfoldr)
import Data.Char (intToDigit)
toBase :: Int -> Int -> String▼
toBase intBase n =▼
if (intBase < 36) && (intBase > 0)▼
then inBaseDigits (take intBase (['0' .. '9'] ++ ['a' .. 'z'])) n▼
else []▼
inBaseDigits :: [Char] -> Int -> String
Line 1,303 ⟶ 1,297:
inOctal :: Int -> String
inOctal = inBaseDigits "01234567"
▲toBase :: Int -> Int -> String
▲toBase intBase n =
▲ if (intBase < 36) && (intBase > 0)
▲ then inBaseDigits (take intBase (['0' .. '9'] ++ ['a' .. 'z'])) n
▲ else []
main :: IO ()
|