Jump to content

Show ASCII table: Difference between revisions

m
(Add QB64)
Line 2,455:
import Data.List (transpose)
import Data.List.Split (chunksOf)
import Text.Printf (printf)
 
----------------------- ASCII TABLE ----------------------
main :: IO ()
main = putStrLn asciiTable
 
asciiTable :: String
asciiTable =
unlines $
(justifyLeftprintf 12 ' '"%-12s" =<<)
<$> transpose
(chunksOf 16 $ asciiEntry <$> [32 .. 127])
Line 2,469:
asciiEntry n
| null k = k
| otherwise = concat [printf "%3d" n, " : ", k]
concat
[justifyRight 4 ' ' (show n), " : ", k]
where
k = asciiName n
Line 2,483 ⟶ 2,481:
| otherwise = [chr n]
 
 
justifyLeft, justifyRight :: Int -> Char -> String -> String
--------------------------- TEST -------------------------
justifyLeft n c s = take n (s <> replicate n c)
main :: IO ()
justifyRight n c = (drop . length) <*> (replicate n c <>)</lang>
main = putStrLn asciiTable
</lang>
{{Out}}
<pre> 32 : Spc 48 : 0 64 : @ 80 : P 96 : ` 112 : p
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.