September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,21 +1,22 @@
/*REXX program displays a spiral in a square array (of any size) from a start number.*/
parse arg size . /*obtain optional arguments from the CL*/
if size=='' | size=="," then size=5 /*Not specified? Then use the default.*/
tot=size**2; L=length(tot) /*total number of elements in spiral. */
/*REXX program displays a spiral in a square array (of any size) starting at START. */
parse arg size start . /*obtain optional arguments from the CL*/
if size =='' | size =="," then size =5 /*Not specified? Then use the default.*/
if start=='' | start=="," then start=0 /*Not specified? Then use the default.*/
tot=size**2; L=length(tot + start) /*total number of elements in spiral. */
k=size /*K: is the counter for the spiral. */
row=1; col=0; start=0 /*start spiral at row 1, column 0. */
row=1; col=0 /*start spiral at row 1, column 0. */
/* [↓] construct the numbered spiral. */
do n=start for k; col=col+1; @.col.row=n; end; if k==0 then exit
do n=0 for k; col=col + 1; @.col.row=n + start; end; if k==0 then exit
/* [↑] build the first row of spiral. */
do until n>=tot /*spiral matrix.*/
do one=1 to -1 by -2 until n>=tot; k=k-1 /*perform twice.*/
do n=n for k; row=row+one; @.col.row=n; end /*for the row···*/
do n=n for k; col=col-one; @.col.row=n; end /* " " col···*/
do n=n for k; row=row + one; @.col.row=n + start; end /*for the row···*/
do n=n for k; col=col - one; @.col.row=n + start; end /* " " col···*/
end /*one*/ /* ↑↓ direction.*/
end /*until n≥tot*/ /* [↑] done with the matrix spiral. */
/* [↓] display spiral to the screen. */
do r=1 for size; _= right(@.1.r, L) /*construct display row by row. */
do c=2 for size-1; _=_ right(@.c.r, L) /*construct a line for the display. */
do r=1 for size; _= right(@.1.r, L) /*construct display row by row. */
do c=2 for size -1; _=_ right(@.c.r, L) /*construct a line for the display. */
end /*col*/ /* [↑] line has an extra leading blank*/
say _ /*display a line (row) of the sprial. */
say _ /*display a line (row) of the spiral. */
end /*row*/ /*stick a fork in it, we're all done. */

View file

@ -1,16 +1,17 @@
/*REXX program displays a spiral in a square array (of any size) from a start number.*/
parse arg size . /*obtain optional arguments from the CL*/
if size=='' | size=="," then size=5 /*Not specified? Then use the default.*/
tot=size**2; L=length(tot) /*total number of elements in spiral. */
/*REXX program displays a spiral in a square array (of any size) starting at START. */
parse arg size start . /*obtain optional arguments from the CL*/
if size =='' | size =="," then size =5 /*Not specified? Then use the default.*/
if start=='' | start=="," then start=0 /*Not specified? Then use the default.*/
tot=size**2; L=length(tot + start) /*total number of elements in spiral. */
k=size /*K: is the counter for the spiral. */
row=1; col=0; start=0 /*start spiral at row 1, column 0. */
row=1; col=0 /*start spiral at row 1, column 0. */
/* [↓] construct the numbered spiral. */
do n=start for k; col=col+1; @.col.row=n; end; if k==0 then exit
do n=0 for k; col=col + 1; @.col.row=n + start; end; if k==0 then exit
/* [↑] build the first row of spiral. */
do until n>=tot /*spiral matrix.*/
do one=1 to -1 by -2 until n>=tot; k=k-1 /*perform twice.*/
do n=n for k; row=row+one; @.col.row=n; end /*for the row···*/
do n=n for k; col=col-one; @.col.row=n; end /* " " col···*/
do one=1 to -1 by -2 until n>=tot; k=k - 1 /*perform twice.*/
do n=n for k; row=row + one; @.col.row=n + start; end /*for the row···*/
do n=n for k; col=col - one; @.col.row=n + start; end /* " " col···*/
end /*one*/ /* ↑↓ direction.*/
end /*until n≥tot*/ /* [↑] done with the matrix spiral. */
!.=0 /* [↓] display spiral to the screen. */
@ -20,6 +21,6 @@ row=1; col=0; start=0 /*start spiral at row 1, co
if two then _=_ right(x, !.c) /*construct a line for the display. */
else !.c=max(!.c, length(x)) /*find the maximum width of the column.*/
end /*c*/ /* [↓] line has an extra leading blank*/
if two then say substr(_,2) /*this SUBSTR ignores the first blank. */
if two then say substr(_, 2) /*this SUBSTR ignores the first blank. */
end /*r*/
end /*two*/ /*stick a fork in it, we're all done. */