2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -6,11 +6,11 @@ import Text.Printf
|
|||
toBin n = showIntAtBase 2 ("01" !!) n ""
|
||||
|
||||
-- Implement our own version.
|
||||
toBin' 0 = []
|
||||
toBin' x = (toBin' $ x `div` 2) ++ (show $ x `mod` 2)
|
||||
toBin1 0 = []
|
||||
toBin1 x = (toBin1 $ x `div` 2) ++ (show $ x `mod` 2)
|
||||
|
||||
printToBin n = putStrLn $ printf "%4d %14s %14s" n (toBin n) (toBin' n)
|
||||
printToBin n = putStrLn $ printf "%4d %14s %14s" n (toBin n) (toBin1 n)
|
||||
|
||||
main = do
|
||||
putStrLn $ printf "%4s %14s %14s" "N" "toBin" "toBin'"
|
||||
putStrLn $ printf "%4s %14s %14s" "N" "toBin" "toBin1"
|
||||
mapM_ printToBin [5, 50, 9000]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue