RosettaCodeData/Task/Variable-length-quantity/Haskell/variable-length-quantity-1.hs

16 lines
305 B
Haskell
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
import Numeric (readOct, showOct)
import Data.List (intercalate)
2013-10-27 22:24:23 +00:00
2017-09-23 10:01:46 +02:00
to :: Int -> String
2013-10-27 22:24:23 +00:00
to = flip showOct ""
2017-09-23 10:01:46 +02:00
from :: String -> Int
2013-10-27 22:24:23 +00:00
from = fst . head . readOct
2017-09-23 10:01:46 +02:00
main :: IO ()
main =
mapM_
(putStrLn .
intercalate " <-> " . (pure (:) <*> to <*> (return . show . from . to)))
[2097152, 2097151]