Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,31 +1,31 @@
/*REXX program sorts an array using the selection-sort method. */
@.='' /*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 items=1 until @.items=='' /*find # items.*/
end
items=items-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.*/
/*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────────────*/
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
_=@.j; @.j=@.p; @.p=_
end /*j*/
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