Multiplication tables: Difference between revisions
m
→{{header|Haskell}}
Line 2,814:
table :: [Int] -> [[Maybe Int]]
table xs =
zipWith
[ [ bool (Just (x * y)) Nothing (x > y)
where
axis =
--
main :: IO ()
main =
(putStrLn . unlines) $
--
showTable :: [[Maybe Int]] -> String
showTable xs = unlines $ head rows : [] : tail rows
where
rows = (maybe gap (rjust w ' ' . show) =<<) <$> xs
rjust :: Int -> Char -> String -> String
rjust n c = (drop . length) <*> (replicate n c ++)</lang>
{{Out}}
<pre> 13 14 15 16 17 18 19 20
|