Multiplication tables: Difference between revisions
→{{header|Haskell}}: Switched core type from [Int] to Maybe Int
(→{{header|Haskell}}: Switched core type from [Int] to Maybe Int) |
|||
Line 2,254:
Or, making do without imports beyond the Prelude, and separating data from formatting:
<lang Haskell>multTable :: Int -> [[
multTable n =
(\y -> if y < x then Nothing else Just (x *
where range = [1..n]
tableString :: [[
tableString tbl =
unlines $ (concat . (fmt <$>)) <$> tbl
where▼
pad = " "▼
fmt [ ] = pad▼
fmt [e] = drop (length s) (pad ++ s)▼
where
pad
▲ where
main :: IO ()
|