Multiplication tables: Difference between revisions
→{{header|Haskell}}: Simpler route to max integer string length
(→{{header|Haskell}}: Adjusted for more flexible column widths (for larger tables and longer integer strings)) |
(→{{header|Haskell}}: Simpler route to max integer string length) |
||
Line 2,326:
multTable n =
(\x ->
(mappend (show x) ":") :
((\y ->
if y < x
Line 2,333:
[1 .. n])) <$>
[1 .. n]
tableString :: Int -> String
tableString n = unlines $ (unwords . ((justifyRight
where
justifyRight n c s = drop (length s) (mappend (replicate n c) s)▼
maxLen = length . mx . (mx <$>)▼
tbl = multTable n
▲ justifyRight n c s = drop (length s) (mappend (replicate n c) s)
main :: IO ()
|