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,35 +1,29 @@
/*REXX program sorts a stemmed array using the selection-sort algorithm.*/
@. = /*assign a default value to stem.*/
@.1 = '---The seven hills of Rome:---'
@.2 = '=============================='
@.3 = 'Caelian'
@.4 = 'Palatine'
@.5 = 'Capitoline'
@.6 = 'Virminal'
@.7 = 'Esquiline'
@.8 = 'Quirinal'
@.9 = 'Aventine'
do k=1 until @.k=='' /*find the number of array items.*/
end /*k*/ /* [↑] find the "null" item. */
items=k-1 /*adjust the # of items slightly.*/
call show@ 'before sort' /*show the before array elements,*/
call selectionSort items /*invoke the selection sort. */
call show@ ' after sort' /*show the after array elements.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SELECTIONSORT subroutine────────────*/
/*REXX program sorts a stemmed array using the selection-sort algorithm. */
@.=; @.1 = '---The seven hills of Rome:---'
@.2 = '=============================='
@.3 = 'Caelian'
@.4 = 'Palatine'
@.5 = 'Capitoline'
@.6 = 'Virminal'
@.7 = 'Esquiline'
@.8 = 'Quirinal'
@.9 = 'Aventine'
do #=1 until @.#==''; end; #=#-1 /*find the number of items in the array*/
/* [↑] adjust # ('cause of DO index)*/
call show 'before sort' /*show the before array elements. */
say copies('', 65) /*show a nice separator line (fence). */
call selectionSort # /*invoke selection sort (and # items). */
call show ' after sort' /*show the after array elements. */
exit /*stick a fork in it, we're a;; done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
selectionSort: procedure expose @.; parse arg n
do j=1 for n-1
_=@.j; p=j; do k=j+1 to n
if @.k<_ then do; _=@.k; p=k; end
end /*k*/
if p==j then iterate /*if the same, order of items OK.*/
_=@.j; @.j=@.p; @.p=_ /*swap two items out-of-sequence.*/
end /*j*/
return
/*──────────────────────────────────SHOW@ subroutine────────────────────*/
show@: w=length(items); do i=1 for items
say 'element' right(i,w) arg(1)":" @.i
end /*i*/
say copies('',79) /*show a nice separator line. */
return
do j=1 for n-1
_=@.j; p=j; do k=j+1 to n
if @.k<_ then do; _=@.k; p=k; end
end /*k*/
if p==j then iterate /*if the same, the order of items OK. */
_=@.j; @.j=@.p; @.p=_ /*swap 2 items that're out-of-sequence.*/
end /*j*/
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: do i=1 for #; say ' element' right(i,length(#)) arg(1)":" @.i; end; return