Multiplication tables: Difference between revisions
m
→{{header|Haskell}}
m (→{{header|Haskell}}: Tidied, removed one import.) |
|||
Line 3,522:
mulTable :: [Int] -> [[Maybe Int]]
mulTable xs =
(Nothing :
zipWith
(:)
[[upperMul x y | y <- xs] | x <- xs]
where
upperMul x y
| x > y = Nothing
Line 3,537:
main :: IO ()
main =
showTable . mulTable
<$> [ [13 .. 20],
Line 3,548:
showTable xs = unlines $ head rows : [] : tail rows
where
w =
gap = replicate w ' '
rows = (maybe gap (rjust w ' ' . show) =<<) <$> xs
|