Multiplication tables: Difference between revisions
→{{header|Python}}: Generalised column alignment for tables of other orders
(→{{header|Python}}: Generalised column alignment for tables of other orders) |
|||
Line 4,140:
without redundant entries beneath
the diagonal of squares.'''
# colWidth :: Int
colWidth = len(str(n * n))
# pad :: String -> String
def pad(s):
return s.rjust(colWidth, ' ')
xs = enumFromTo(1)(n)
return unlines([
pad(str(y
pad(str(x * y)
else pad('
]) for y in xs
])
Line 4,183 ⟶ 4,191:
main()</lang>
{{Out}}
<pre> 1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
=={{header|R}}==
|