File: num006.hs

package info (click to toggle)
ghc 8.0.1-17
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 55,080 kB
  • ctags: 9,332
  • sloc: haskell: 363,120; ansic: 54,900; sh: 4,782; makefile: 974; perl: 542; asm: 315; python: 306; xml: 154; lisp: 7
file content (28 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Exercising the showing of positive numbers at various bases.
--
module Main(main) where

import Numeric
import Data.Char

--showDec :: Integral a => a -> ShowS
showDec = showInt

{-
--showBinary :: Integral a => a -> ShowS
showBinary n r =
 showString "0b" $
 showIntAtBase 2 (toChr) n r
 where toChr d = chr (ord '0' + fromIntegral d)
-}

main =
 do
  print (map (\ x -> showOct x []) [1..32])
  print (map (\ x -> showDec x []) [1..32])
  print (map (\ x -> showHex x []) [1..32])
--  print (map (\ x -> showBinary x []) [1..32])
  putStrLn (showOct (241324784::Int) [])
  putStrLn (showDec (241324784::Int) [])
  putStrLn (showHex (241324784::Int) [])
---  putStrLn (showBinary (241324784::Int) [])