2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,60 +1,55 @@
/*REXX program displays a NxN multiplication table (in a boxed grid). */
parse arg high . /*get optional grid size from the C.L. */
if high=='' then high=12 /*Not specified? Then use the default.*/
bar = '' ; dash = '' /*(vertical) bar; horizontal bar (dash)*/
bj = '' ; tj = '' /*bottom and top junctions (or tees).*/
cj = '' /*center junction (or cross). */
lj = '' ; rj = '' /*left and right junctions (or tees).*/
tlc = '' ; trc = '' /* top left and right corners. */
blc = '' ; brc = '' /*bottom " " " " */
/* [↑] define stuff to hold box glyphs*/
cell = cj || copies(dash, 5) /*define the top of the cell. */
sep = copies(cell, high+1)rj /*build the table separator. */
sepL = length(sep) /*length of the separator line. */
width= length(cell)-1 /*width of the table cells. */
size = width-1 /*width for the table numbers. */
box. = left('', width) /*construct all the cells. */
/*REXX program displays a NxN multiplication table (in a boxed grid) to the terminal.*/
parse arg high . /*obtain optional grid size from the CL*/
if high=='' | high=="," then high=12 /*Not specified? Then use the default.*/
bar = '' ; dash = "" /*(vertical) bar; horizontal bar (dash)*/
bj = '' ; tj = "" /*bottom and top junctions (or tees).*/
cj = '' /*center junction (or cross). */
lj = '' ; rj = "" /*left and right junctions (or tees).*/
tlc = '' ; trc = "" /* top left and right corners. */
blc = '' ; brc = "" /*bottom " " " " */
/* [↑] 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*/
do j=0 to high /*step through zero ───► high. */
_=right(j, size-1)'x ' /*build the "label" (border) number. */
box.0.j=_ /*build the top label cell. */
box.j.0=_ /*build the left label cell. */
do j=0 to high /*step through zero ───► high. */
_=right(j, size - 2)'x ' /*build the "label" (border) number. */
box.0.j=center(_, size) /* " " top label cell. */
box.j.0=center(_, max(5, size) ) /* " " left label cell. */
end /*j*/
box.0.0=centre('times', width) /*redefine box.0.0 with 'X'. */
box.0.0=center('times', max(5, size)) /*redefine box.0.0 with "times". */
do row=1 for high /*step through one ───► high. */
do col=row to high /*step through row ───► high. */
box.row.col=right(row*col, size)' ' /*build a multiplication cell. */
end /*col*/
end /*row*/
do r=1 for high /*step through row one ───► high. */
do c=r to high /*step through column row ───► high. */
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 row=0 to high /*step through all the lines. */
asep=sep /*allow use of a modified separator. */
if row==0 then do
asep=overlay(tlc, asep, 1) /*make a better tlc. */
asep=overlay(trc, asep, sepL) /*make a better trc. */
asep=translate(asep, tj ,cj) /*make a better tj. */
end
else asep=overlay(lj, asep ,1) /*make a better lj. */
do r=0 to high; @=sep /*step through all lines; use a mod sep*/
if r==0 then do
@=overlay(tlc, @ , 1) /*use a better tlc (top left corner). */
@=overlay(trc, @ , length(sep)) /* " " " trc ( " right " ). */
@=translate(@, tj, cj) /* " " " tj (top junction/tee).*/
end
else @=overlay(lj, @, 1) /* " " " lj (left junction/tee).*/
say @ /*display a single table grid line. */
if r==0 then call buildLine 00 /* " " " blank grid " */
call buildLine r /*build a single line of the grid. */
if r==0 then call buildLine 00 /*display a single blank grid line. */
end /*r*/
say asep /*display a table grid line. */
if row==0 then call buildLine 00 /*display a blank grid line. */
call buildLine row /*build one line of the grid. */
if row==0 then call buildLine 00 /*display a blank grid line. */
end /*row*/
asep=sep /*allow use of a modified separator. */
asep=overlay(blc, asep, 1) /*make a better bottom left corner. */
asep=overlay(brc, asep, sepL) /*make a better bottom right corner. */
asep=translate(asep, bj, cj) /*make a better bottom junction. */
say asep /*display a table grid line. */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
buildLine: w=; parse arg arow /*start with a blank cell. */
do col=0 to high /*step through zero ───► high. */
w=w||bar||box.arow.col /*build one cell at a time. */
end /*col*/
say w || bar /*finish building the last cell. */
return
@=sep /*allow use of a modified separator. */
@=overlay(blc, @ , 1) /*use a better bottom left corner. */
@=overlay(brc, @ , length(sep) ) /* " " " " right corner. */
@=translate(@, bj, cj) /* " " " " junction. */
say @ /*display a (single) table grid line. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
buildLine: parse arg row,,$ /*start with a blank cell ($). */
do col=0 to high /*step through zero ───► high. */
$=$ || bar || box.row.col /*build one cell at a time. */
end /*col*/
say $ || bar /*finish building the last cell.*/
return