Show ASCII table: Difference between revisions
m
→{{header|Haskell}}: Tidied. Used chunksOf from Data.List.Split
m (→{{header|Haskell}}: Tidied. Used chunksOf from Data.List.Split) |
|||
Line 1,702:
=={{header|Haskell}}==
<lang haskell>import Data.List (intercalate, transpose)
import Data.List.Split (chunksOf)
import Data.Char (chr)
main :: IO ()▼
main = putStrLn asciiTable▼
asciiTable :: String
Line 1,710 ⟶ 1,714:
transpose (chunksOf 16 $ asciiEntry <$> [32 .. 127])
▲main :: IO ()
▲main = putStrLn asciiTable
asciiEntry :: Int -> String
asciiEntry n
where▼
k = asciiName n
▲ _ -> concat [justifyRight 4 ' ' (show n), " : ", k]
asciiName :: Int -> String
Line 1,728:
| 127 == n = "Del"
| otherwise = [chr n]
▲ where
justifyLeft, justifyRight :: Int -> Char -> String -> String
justifyLeft n c s = take n (s
justifyRight n c
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
|