Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import Data.List (intercalate)
to :: Int -> Int -> [Int]
to _ 0 = []
to base i = to base q <> [r]
where
(q, r) = quotRem i base
from :: Int -> [Int] -> Int
from base = foldl1 ((+) . (base *))
--------------------------- TEST ---------------------------
main :: IO ()
main =
mapM_
(putStrLn .
intercalate " <-> " .
(((:) . (=<<) show . toBase) <*> (return . show . fromBase . toBase)))
[2097152, 2097151]
where
b = 8
fromBase = from b
toBase = to b