Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,33 +1,33 @@
/*REXX program to list non-continuous subsequences (NCS), given a seq.*/
parse arg list /*the the list from the CL.*/
if list='' then list=1 2 3 4 5 /*Specified? Use default. */
say 'list=' space(list); say /*show list to the terminal*/
w=words(list) ; #=0 /*# words in list; # of NCS*/
$=left(123456789,w) /*build a string of digits.*/
tail=right($,max(0,w-2)) /*construct a "fast" tail. */
/*REXX program lists non-continuous subsequences (NCS), given a sequence. */
parse arg list /*obtain the list from the C.L. */
if list='' then list=1 2 3 4 5 /*Not specified? Use the default*/
say 'list=' space(list); say /*display the list to terminal. */
w=words(list) ; #=0 /*W: words in list; # of NCS. */
$=left(123456789,w) /*build a string of decimal digs.*/
tail=right($,max(0,w-2)) /*construct a "fast" tail. */
do j=13 to left($,1) || tail /*step through the list. */
if verify(j,$)\==0 then iterate /*Not one of the chosen? */
f=left(j,1) /*the first digit of j. */
NCS=0 /*not non-continuous subseq*/
do k=2 to length(j); _=substr(j,k,1) /*pick off a single digit. */
if _ <= f then iterate j /*if next digit ≤ then skip*/
if _ \== f+1 then NCS=1 /*it's OK as of now. */
f=_ /*we now got a new next dig*/
do j=13 to left($,1) || tail /*step through the list. */
if verify(j,$)\==0 then iterate /*Not one of the chosen? */
f=left(j,1) /*use the 1st decimal digit of J.*/
NCS=0 /*not non-continuous subsequence.*/
do k=2 to length(j); _=substr(j,k,1) /*pick off a single decimal digit*/
if _ <= f then iterate j /*if next digit ≤, then skip it.*/
if _ \== f+1 then NCS=1 /*it's OK as of now. */
f=_ /*now have a new next decimal dig*/
end /*k*/
if \NCS then iterate /*¬OK? Then skip this num.*/
#=#+1 /*Eureka! We found one. */
x= /*the beginning of the NCS.*/
do m=1 for length(j) /*build a thingy to display*/
x=x word(list,substr(j,m,1)) /*pick off a number to show*/
if \NCS then iterate /*not OK? Then skip this number.*/
#=#+1 /*Eureka! We found onea digit.*/
x= /*the beginning of the NCS. */
do m=1 for length(j) /*build a sequence string to show*/
x=x word(list,substr(j,m,1)) /*pick off a number to display. */
end /*m*/
say 'a non-continuous subsequence: ' x /*show a non-cont. subseq. */
end /*j*/
say 'a non-continuous subsequence: ' x /*show non─continous subsequence.*/
end /*j*/
if #==0 then #='no' /*make it more gooder Eng. */
if #==0 then #='no' /*make it more gooder Anglesh. */
say; say # "non-continuous subsequence"s(#) 'were found.'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────S subroutine───────────────────────*/
s: if arg(1)==1 then return ''; return word(arg(2) 's',1) /*plurals.*/
exit /*stick a fork in it, we're done.*/
/*────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return ''; return word(arg(2) 's',1) /*plurals.*/