Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
/*REXX program creates a range extraction from a list of numbers (can be negative.) */
old=0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 35 36 37 38 39
#= words(old) /*number of integers in the number list*/
new= /*the new list, possibly with ranges. */
do j=1 to #; z= word(old, j) /*obtain Jth number in the old list. */
inc= 1; new= new','z /*append " " to " new " */
do k=j+1 to #; y= word(old, k) /*get the Kth number in the number list*/
if y\==z+inc then leave /*is this number not > previous by inc?*/
inc= inc + 1; g= y /*increase the range, assign G (good).*/
end /*k*/
if k-1=j | g=z+1 then iterate /*Is the range=0│1? Then keep truckin'*/
new= new'-'g; j= k - 1 /*indicate a range of #s; change index*/
end /*j*/
/*stick a fork in it, we're all done. */
new= substr(new, 2) /*elide the leading comma in the range.*/
say 'old:' old; say 'new:' new /*show the old and new range of numbers*/

View file

@ -0,0 +1,16 @@
/*REXX program creates a range extraction from a list of numbers (can be negative.) */
old=0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 35 36 37 38 39
#= words(old); j= 0 /*number of integers in the number list*/
new= /*the new list, possibly with ranges. */
do while j<#; j= j + 1; z= word(old, j) /*get the Jth number in the number list*/
inc= 1; new= new','z /*append " " to " new " */
do k=j+1 to #; y= word(old, k) /*get the Kth number in the number list*/
if y\==z+inc then leave /*is this number not > previous by inc?*/
inc= inc + 1; g= y /*increase the range, assign G (good).*/
end /*k*/
if k-1=j | g=z+1 then iterate /*Is the range=0│1? Then keep truckin'*/
new= new'-'g; j= k - 1 /*indicate a range of numbers; change J*/
end /*while*/
/*stick a fork in it, we're all done. */
new= substr(new, 2) /*elide the leading comma in the list. */
say 'old:' old; say 'new:' new /*show the old and new range of numbers*/

View file

@ -0,0 +1,31 @@
/*REXX program to test range extraction. ******************************
* 07.08.2012 Walter Pachl
**********************************************************************/
aaa='0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29',
'30 31 32 33 35 36 37 38 39'
say 'old='aaa;
aaa=aaa 1e99 /* artificial number at the end */
i=0 /* initialize index */
ol='' /* initialize output string */
comma='' /* will become a ',' lateron */
inrange=0
Do While i<=words(aaa) /* loop for all numbers */
i=i+1 /* index of next number */
n=word(aaa,i) /* the now current number */
If n=1e99 Then Leave /* we are at the end */
If inrange Then Do /* range was opened */
If word(aaa,i+1)<>n+1 Then Do /* following word not in range */
ol=ol||n /* so this number is the end */
inrange=0 /* and the range is over */
End /* else ignore current number */
End
Else Do /* not in a range */
ol=ol||comma||n /* add number (with comma) */
comma=',' /* to the output string */
If word(aaa,i+2)=n+2 Then Do /* if the nr after the next fits */
inrange=1 /* open a range */
ol=ol'-' /* append the range connector */
End
End
End
Say 'new='ol