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,37 +1,37 @@
/*REXX program sorts (E-sort) an arra y (which contains integers). */
numeric digits 30 /*handle larger Euler numbers. */
@. = 0 /*default for all Euler numbers. */
@.1= 1
@.3= -1
@.5= 5
@.7= -61
@.9= 1385
@.11= -50521
@.13= 2702765
@.15= -199360981
@.17= 19391512145
@.19= -2404879675441
@.21= 370371188237525
size=21 /*indicate there are 21 Euler #'s*/
call tell 'un-sorted' /*display the array before sort. */
call esort size /*sort the array of Euler numbers*/
call tell ' sorted' /*display the array after sort. */
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────ESORT subroutine────────────────────*/
esort: procedure expose @.; parse arg N; h=N
do while h>1; h=h%2
do i=1 for N-h; j=i; k=h+i
do while @.k<@.j
parse value @.j @.k with @.k @.j /*swap two elements.*/
if h>=j then leave; j=j-h; k=k-h
end /*while @.k<@.j*/
end /*i*/
end /*while h>1*/
return
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: say center(arg(1),50,'')
do j=1 for size
say arg(1) 'array element' right(j,length(size))'='right(@.j,20)
end /*j*/
say
return
/*REXX program sorts an array (using E-sort), in this case, the array contains integers.*/
numeric digits 30 /*enables handling larger Euler numbers*/
@. = 0 /*the default for all Euler numbers. */
@.1 = 1
@.3 = -1
@.5 = 5
@.7 = -61
@.9 = 1385
@.11= -50521
@.13= 2702765
@.15= -199360981
@.17= 19391512145
@.19= -2404879675441
@.21= 370371188237525
size=21 /*indicate that there're 21 Euler #s.*/
call tell 'un-sorted' /*display the array before the eSsort. */
call eSort size /*sort the array of some Euler numbers.*/
call tell ' sorted' /*display the array after the sort. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
eSort: procedure expose @.; parse arg N; h=N
do while h>1; h=h%2
do i=1 for N-h; j=i; k=h+i
do while @.k<@.j
parse value @.j @.k with @.k @.j /*swap two array elements.*/
if h>=j then leave; j=j-h; k=k-h
end /*while @.k<@.j*/
end /*i*/
end /*while h>1*/
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
tell: say center(arg(1), 50, '')
do j=1 for size
say arg(1) 'array element' right(j, length(size))'='right(@.j, 20)
end /*j*/
say
return

View file

@ -1,29 +1,28 @@
/*REXX program sorts (using E-sort) a list of some interesting integers.*/
/* [↓] quotes aren't needed if all elements in a list are non-negative.*/
bell= 1 1 2 5 15 52 203 877 4140 21147 115975 /*some Bell numbers.*/
bern= '1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617' /*some Bernoulli num*/
perrin= 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90 /*some Perrin nums. */
list=bell bern perrin /*throw 'em───►a pot*/
say 'unsorted =' list /*an announcement···*/
size=words(list) /*nice to have SIZE.*/
do j=1 for size /*build an array, 1 */
@.j=word(list,j) /*element at a time.*/
end /*j*/
call esort size /*sort the stuff. */
bList= /*list: null so far.*/
do k=1 for size /*build a list. */
bList=strip(bList @.k) /*append it to list.*/
end /*k*/
say ' sorted =' bList /*show & tell time. */
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────ESORT subroutine────────────────────*/
esort: procedure expose @.; parse arg N; h=N /*get the item count*/
do while h>1; h=h%2 /*partition array. */
do i=1 for N-h; j=i; k=h+i
do while @.k<@.j
parse value @.j @.k with @.k @.j /*swap two elements.*/
if h>=j then leave; j=j-h; k=k-h
end /*while @.k<@.j*/
end /*i*/
end /*while h>1*/
return
/*REXX program sorts (using E─sort) and displays a list of some interesting integers. */
Bell= 1 1 2 5 15 52 203 877 4140 21147 115975 /*a few Bell " */
Bern= '1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617' /*" " Bernoulli " */
Perrin= 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90 /*" " Perrin " */
list=Bell Bern Perrin /*throw them all ───► a pot. */
say 'unsorted =' list /*display what's being shown.*/
size=words(list) /*nice to have # of elements.*/
do j=1 for size /*build an array, a single */
@.j=word(list,j) /* ··· element at a time.*/
end /*j*/
call eSort size /*sort the collection of #s. */
$= /*list: define as null so far*/
do k=1 for size /*build a list from the array*/
$=$ @.k /*append a number to the list*/
end /*k*/
say ' sorted =' space($) /*display the sorted list. */
exit /*stick a fork in it, we're all done.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
eSort: procedure expose @.; parse arg N; h=N /*get item count for array. */
do while h>1; h=h%2 /*partition the array. */
do i=1 for N-h; j=i; k=h+i
do while @.k<@.j /*keep swapping while less. */
parse value @.j @.k with @.k @.j /*swap two array elements. */
if h>=j then leave; j=j-h; k=k-h
end /*while @.k<@.j*/
end /*i*/
end /*while h>1*/
return