September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,10 +1,15 @@
|
|||
import Numeric
|
||||
import Numeric (readOct, showOct)
|
||||
import Data.List (intercalate)
|
||||
|
||||
to :: Int -> String
|
||||
to = flip showOct ""
|
||||
|
||||
from :: String -> Int
|
||||
from = fst . head . readOct
|
||||
|
||||
main = do
|
||||
fancy 2097152
|
||||
fancy 2097151
|
||||
where fancy i = putStrLn $ to i ++ " <-> " ++ show (from $ to i)
|
||||
main :: IO ()
|
||||
main =
|
||||
mapM_
|
||||
(putStrLn .
|
||||
intercalate " <-> " . (pure (:) <*> to <*> (return . show . from . to)))
|
||||
[2097152, 2097151]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,19 @@
|
|||
import Data.List (intercalate)
|
||||
|
||||
base :: Int
|
||||
base = 8
|
||||
|
||||
to :: Int -> [Int]
|
||||
to 0 = []
|
||||
to i = to (div i base) ++ [mod i base]
|
||||
|
||||
from = foldl1 (\x y -> x*base + y)
|
||||
from :: [Int] -> Int
|
||||
from = foldl1 ((+) . (base *))
|
||||
|
||||
main = do
|
||||
fancy 2097152
|
||||
fancy 2097151
|
||||
where fancy i = putStrLn $ concatMap show (to i) ++ " <-> " ++ show (from $ to i)
|
||||
main :: IO ()
|
||||
main =
|
||||
mapM_
|
||||
(putStrLn .
|
||||
intercalate " <-> " .
|
||||
(((:) . concatMap show . to) <*> (return . show . from . to)))
|
||||
[2097152, 2097151]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue