Multiplication tables: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: or, a Prelude - only version) |
|||
Line 2,256: | Line 2,256: | ||
table n = concat <$> xs |
table n = concat <$> xs |
||
where |
where |
||
xs = concatMap (\x -> [[fmt x] ++ [ |
xs = concatMap (\x -> [[fmt x] ++ [drop 2 pad] ++ |
||
concatMap (\y -> if y < x then [ |
concatMap (\y -> if y < x then [pad] |
||
else [fmt $ x * y]) |
else [fmt $ x * y]) |
||
range]) |
range]) |
||
range |
range |
||
where |
where |
||
fmt e = drop (length s) ( |
fmt e = drop (length s) (pad ++ s) |
||
where |
where |
||
s = show e |
s = show e |
||
pad = " " |
|||
range = [1..n] |
range = [1..n] |
||