Show ASCII table: Difference between revisions

m
→‎{{header|Haskell}}: Pruned out one unused import.
(→‎{{header|AWK}}: Removed unused or not very useful code)
m (→‎{{header|Haskell}}: Pruned out one unused import.)
Line 1,749:
 
=={{header|Haskell}}==
<lang haskell>import Data.List.Split (intercalate, transposechunksOf)
import Data.List.Split (chunksOftranspose)
import Data.Char (chr)
 
main :: IO ()
main = putStrLn asciiTable
 
asciiTable :: String
asciiTable =
Line 1,761:
(justifyLeft 12 ' ' =<<) <$>
transpose (chunksOf 16 $ asciiEntry <$> [32 .. 127])
 
asciiEntry :: Int -> String
asciiEntry n
Line 1,768:
where
k = asciiName n
 
asciiName :: Int -> String
asciiName n
Line 1,776:
| 127 == n = "Del"
| otherwise = [chr n]
 
justifyLeft, justifyRight :: Int -> Char -> String -> String
justifyLeft n c s = take n (s <> replicate n c)
 
justifyRight n c = (drop . length) <*> (replicate n c <>)</lang>
{{Out}}
9,659

edits