Anonymous user
Multiplication tables: Difference between revisions
m
→{{header|REXX}}: added DO-END labels, added comments, added whitespace. -- ~~~~
m (→{{header|F#}}: header cleanup) |
m (→{{header|REXX}}: added DO-END labels, added comments, added whitespace. -- ~~~~) |
||
Line 1,971:
=={{header|REXX}}==
<lang REXX>/*REXX program
if high=='' then high=12 /*not specified? Use default. */
if ebcdic then do /*══════════EBCDIC═══════════════*/
▲/*grid will be displayed in "boxing" characters for ASCII or EBCDIC */
cj ='8f'x /*center junction (cross). */▼
▲ tj ='cc'x /* top junction. */
▲ cj ='8f'x /*center junction (cross). */
▲ lj ='eb'x /* left junction. */
▲ rj ='ec'x /* right junction. */
tlc='ac'x /*top left corner. */▼
trc='bc'x /*top right corner. */▼
blc='ab'x /*bottom left corner. */▼
brc='bb'x /*bottom right corner. */▼
end
else do /*
bar='b3'x /*vertical bar. */
dash='c4'x /*horizontal dash. */
bj ='c1'x /*bottom junction. */
tj ='c2'x /* top junction. */
cj ='c5'x /*center junction (cross). */
lj ='c3'x /* left junction. */
rj ='b4'x /* right junction. */
tlc='da'x /*top left corner. */
trc='bf'x /*top right corner. */
blc='c0'x /*bottom left corner. */
brc='d9'x /*bottom right corner. */
end
cell=cj || copies(dash,5)
sep=copies(cell,high+1)rj /*build the table separator. */
sepL=length(sep) /*length of separator line. */
width=length(cell)-1 /*width of the table cells. */
size=width-1 /*width for table numbers. */
box.=left('',width) /*construct all the cells. */▼
▲box.=left('',width) /*construct all cells. */
do j=0 to high /*step through zero to H (12)*/▼
_=right(j,size-1)'x ' /*build "label"/border number*/▼
▲ box.0.j=_ /*build top label cell. */
do
end /*j*/
end /*col*/
end /*row*/
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. */
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 sep. */
asep=overlay(blc,asep,1) /*make a better bot left
asep=overlay(brc,asep,sepL) /*make a better bot right
asep=translate(asep,bj,cj) /*make a better bot junction. */
say asep /*display a table grid line. */
/*──────────────────────────────────BUILDLINE subroutine────────────────*/
buildLine: w=; parse arg arow /*start with a blank cell. */
end /*col*/
return</lang>
'''output'''
<pre style="height:
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ │ │ │ │ │ │ │ │ │ │ │ │ │
Line 2,098 ⟶ 2,085:
│ 12x │ │ │ │ │ │ │ │ │ │ │ │ 144 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
</pre>
'''output''' when the following is used for input: <tt> 10 </tt>
▲<pre style="height:30ex;overflow:scroll">
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ │ │ │ │ │ │ │ │ │ │ │
Line 2,135 ⟶ 2,113:
│ 10x │ │ │ │ │ │ │ │ │ │ 100 │
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
</pre>
|