Multiplication tables: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: map -> fmap) |
|||
Line 2,257: | Line 2,257: | ||
table n = concat <$> xs |
table n = concat <$> xs |
||
where |
where |
||
xs = |
xs = (\x -> fmt x : drop 2 pad : ( |
||
(\y -> if y < x then pad else fmt $ x * y) |
|||
<$> range)) |
|||
<$> range |
|||
range |
|||
where |
where |
||
fmt e = drop (length s) (pad ++ s) |
fmt e = drop (length s) (pad ++ s) |
||
Line 2,268: | Line 2,267: | ||
pad = " " |
pad = " " |
||
range = [1..n] |
range = [1..n] |
||
main :: IO () |
main :: IO () |
||
main = mapM_ putStrLn $ table 12</lang> |
main = mapM_ putStrLn $ table 12</lang> |