Multiplication tables: Difference between revisions
m
→{{header|Haskell}}
(→{{header|Haskell}}: Separated the table generation from the formatting) |
|||
Line 2,322:
<lang haskell>import Data.List (maximumBy)
import Data.Ord (comparing)
import Data.Monoid
multTable :: Int -> [[String]]
multTable n =
(\x ->
((\y ->
if y < x
Line 2,337 ⟶ 2,338:
tableString tbl =
unlines $
(unwords . (justifyRight
where
justifyRight n c s = drop (length s) ((replicate n c) <> s)
main :: IO ()
|