Multiplication tables: Difference between revisions
m
→{{header|Haskell}}
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,336:
tableString :: [[String]] -> String
tableString tbl = unlines $ (unwords . (justifyRight colWidth ' ' <$>)) <$> tbl
where
colWidth = length $ (last . last) tbl
justifyRight n c s = drop (length s)
main :: IO ()
|