tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
37
Task/Range-extraction/NetRexx/range-extraction.netrexx
Normal file
37
Task/Range-extraction/NetRexx/range-extraction.netrexx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*NetRexx program to test range extraction. ***************************
|
||||
* 07.08.2012 Walter Pachl derived from my Rexx Version
|
||||
* Changes: line continuation in aaa assignment changed
|
||||
* 1e99 -> 999999999
|
||||
* Do -> Loop
|
||||
* words(aaa) -> aaa.words()
|
||||
* word(aaa,i) -> aaa.word(i)
|
||||
**********************************************************************/
|
||||
Say 'NetRexx program derived from Rexx'
|
||||
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'
|
||||
aaa=aaa' 30 31 32 33 35 36 37 38 39'
|
||||
say 'old='aaa;
|
||||
aaa=aaa 999999999 /* artificial number at the end */
|
||||
i=0 /* initialize index */
|
||||
ol='' /* initialize output string */
|
||||
comma='' /* will become a ',' lateron */
|
||||
inrange=0
|
||||
Loop While i<=aaa.words /* loop for all numbers */
|
||||
i=i+1 /* index of next number */
|
||||
n=aaa.word(i) /* the now current number */
|
||||
If n=999999999 Then Leave /* we are at the end */
|
||||
If inrange Then Do /* range was opened */
|
||||
If aaa.word(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 aaa.word(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
|
||||
Loading…
Add table
Add a link
Reference in a new issue