Multiplication tables: Difference between revisions
Content added Content deleted
(→{{header|Python}}: For comparison, added an equivalent list monad version to the list comprehension expression) |
(→{{header|Python}}: Labelled the procedural and functional variants) |
||
Line 4,095: | Line 4,095: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
===Procedural=== |
|||
<lang python>>>> size = 12 |
<lang python>>>> size = 12 |
||
>>> width = len(str(size**2)) |
>>> width = len(str(size**2)) |
||
Line 4,129: | Line 4,130: | ||
<small>(As would using ASCII minus, plus, and pipe characters: "-", "+", "|"; instead of the non-ASCII chars used to draw a frame)</small>. |
<small>(As would using ASCII minus, plus, and pipe characters: "-", "+", "|"; instead of the non-ASCII chars used to draw a frame)</small>. |
||
===Functional=== |
|||
We can define a multiplication table string first in terms of a '''list comprehension''' (''mulTable'' function), |
|||
and then again, for comparison, |
and then again, for comparison, as an equivalent '''list monad''' expression (''mulTable2'' function): |
||
<lang python>'''Multiplication table |
<lang python>'''Multiplication table |