Typo
[packages/base.git] / tests / unicode002.hs
1 module Main where
2
3
4 import Data.Char
5 import Numeric
6
7 header = "Code C P S U L A D"
8
9 preds = [
10 isControl,
11 isPrint,
12 isSpace,
13 isUpper,
14 isLower,
15 isAlpha,
16 isDigit]
17
18 prtBool :: Bool -> String
19
20 prtBool True = "T "
21 prtBool False = "F "
22
23 showCode :: Char -> Int -> String
24
25 showCode c w = code ++ pad
26 where
27 code = show (ord c)
28 l = length code
29 spaces = map anytospace [1..]
30 anytospace _ = ' '
31 pad | l >= w = ""
32 | otherwise = take (w - l) spaces
33
34 charCode :: Char -> String
35
36 rapply a b = b a
37
38 charCode c = (showCode c 5) ++ (foldr1 (++) $ map prtBool $ map (rapply c) preds)
39
40 main = do
41 putStrLn header
42 mapM (putStrLn . charCode) [ (chr 0) .. (chr 6553) ]
43
44