Binary digits: Difference between revisions

Content added Content deleted
m (→‎{{header|SequenceL}}: Removing duplicate SequenceL. Webpage timed out ad request submitted twice.)
(→‎{{header|Haskell}}: syntax highlighting doesn't support `'` --> use `1` instead)
Line 1,161:
 
-- Implement our own version.
toBin'toBin1 0 = []
toBin'toBin1 x = (toBin'toBin1 $ x `div` 2) ++ (show $ x `mod` 2)
 
printToBin n = putStrLn $ printf "%4d %14s %14s" n (toBin n) (toBin'toBin1 n)
 
main = do
putStrLn $ printf "%4s %14s %14s" "N" "toBin" "toBin'toBin1"
mapM_ printToBin [5, 50, 9000]</lang>
Sample output:<pre>
N toBin toBin'toBin1
5 101 101
50 110010 110010