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,26 +1,26 @@
/*REXX program splits a string based on different separator strings.*/
parse arg ? /*get string from command line. */
if ?=='' then ? = "a!===b=!=c" /*None specified? Use default.*/
say 'old string='? /*echo the old string to screen. */
zz = '0'x /*null char, can be most anything*/
seps = '== != =' /*a list of seperators to be used*/
/* [↓] process tokens in SEPS.*/
do j=1 for words(seps) /*parse string with all the seps.*/
sep=word(seps,j) /*pick a separator to use now. */
/* [↓] process chars in the sep*/
do k=1 for length(sep) /*parse for various sep versions.*/
sep=strip(insert(zz,sep,k),,zz) /*allow imbedded "nulls" in sep. */
?=changestr(sep,?,zz) /* ··· but not trailing "nulls". */
/* [↓] process strings in input*/
do until ?==??; ??=? /*keep changing until no more chg*/
?=changestr(zz || zz, ?, zz) /*reduce replicated "nulls". */
end /*until···*/
/* [↓] use BIF or external prog.*/
sep=changestr(zz, sep, '') /*remove true nulls from the sep.*/
end /*k*/
end /*j*/
/*REXX program splits a (character) string based on different separator delimiters.*/
parse arg $ /*obtain optional string from the C.L. */
if $='' then $= "a!===b=!=c" /*None specified? Then use the default*/
say 'old string:' $ /*display the old string to the screen.*/
null= '0'x /*null char. It can be most anything.*/
seps= '== != =' /*list of separator strings to be used.*/
/* [↓] process the tokens in SEPS. */
do j=1 for words(seps) /*parse the string with all the seps. */
sep=word(seps,j) /*pick a separator to use in below code*/
/* [↓] process characters in the sep.*/
do k=1 for length(sep) /*parse for various separator versions.*/
sep=strip(insert(null, sep, k), , null) /*allow imbedded "nulls" in separator, */
$=changestr(sep, $, null) /* ··· but not trailing "nulls". */
/* [↓] process strings in the input. */
do until $==old; old=$ /*keep changing until no more changes. */
$=changestr(null || null, $, null) /*reduce replicated "nulls" in string. */
end /*until*/
/* [↓] use BIF or external program.*/
sep=changestr(null, sep, '') /*remove true nulls from the separator.*/
end /*k*/
end /*j*/
showNull = ' {} ' /*one more thing, display the ···*/
?=changestr(zz,?,showNull) /* ··· showing of "null" chars. */
say 'new string='? /*now, display the new string. */
/*stick a fork in it, we're done.*/
showNull= ' {} ' /*just one more thing, display the ··· */
$=changestr(null, $, showNull) /* ··· showing of "null" chars. */
say 'new string:' $ /*now, display the new string to term. */
/*stick a fork in it, we're all done. */