Anonymous user
Multiplication tables: Difference between revisions
m
→{{header|REXX}}: changed some comments and whitespace.
m (→{{header|REXX}}: changed some comments and whitespace.) |
|||
Line 3,421:
parse arg high . /*obtain optional grid size from the CL*/
if high=='' | high=="," then high=12 /*Not specified? Then use the default.*/
bar = '│'
bj = '┴'
lj = '├'
tlc = '┌'
blc = '└'
/* [↑] define stuff to hold box glyphs*/▼
cell = cj || copies(dash,max(5,length(high) +1)) /*define the top of the cell. */
sep = copies(cell, high+1)rj /*construct the table separator. */
size = length(cell) - 1 /*width for the products in the table. */
box. = left('', size) /*initialize all the cells in the table*/
box.0.0=center('times', max(5, size)) /*redefine box.0.0 with "times". */
do c=r to high /*step through column row ───► high. */
box.r.c=right(r*c, size) /*build a single multiplication cell. */
do
▲box.0.0=center('times', max(5, size)) /*redefine box.0.0 with "times". */
end /*r*/▼
▲ box.r.c=right(r*c, size) /*build a single multiplication cell. */
▲ end /*c*/
▲ end /*r*/ /*only build the top right-half of grid*/
▲ do r=0 to high; @=sep /*step through all lines; use a mod sep*/
▲ @=translate(@, tj, cj) /* " " " tj (top junction/tee).*/
▲ end
▲ else @=overlay(lj, @, 1) /* " " " lj (left junction/tee).*/
▲ if r==0 then call buildLine 00 /* " " " blank grid " */
▲ call buildLine r /*build a single line of the grid. */
▲ end /*r*/
@=sep /*allow use of a modified separator. */
@=overlay(blc, @ , 1) /*use a better bottom left corner. */
Line 3,467 ⟶ 3,461:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
buildLine: parse arg row,,$; do col=0 to
say $ || bar; return
'''output''' when using the default input:
<pre>
|