Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,12 +1,12 @@
|
|||
/*REXX program to remove duplicate elements (items) in a list. */
|
||||
/*REXX program removes any duplicate elements (items) that are in a list. */
|
||||
$= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2'
|
||||
say 'original list:' $
|
||||
say right(words($),13) ' words in the original list.'; say
|
||||
say right(words($),17,'─') 'words in the original list.'; say
|
||||
z=; @.= /*initialize the NEW list and index list*/
|
||||
do j=1 for words($); y=word($,j) /*process the words (items) in the list.*/
|
||||
if @.y=='' then z=z y; @.y=. /*Not duplicated? Add to Z list, @ array*/
|
||||
end /*j*/
|
||||
|
||||
do j=words($) by -1 to 1; y=word($,j) /*process words in the list, */
|
||||
_=wordpos(y, $, j+1); if _\==0 then $=delword($, _, 1) /*del if dup.*/
|
||||
end /*j*/
|
||||
|
||||
say 'modified list:' space($)
|
||||
say right(words($),13) ' words in the modified list.'
|
||||
/*stick a fork in it, we're done.*/
|
||||
say 'modified list:' space(z)
|
||||
say right(words(z),17,'─') 'words in the modified list.'
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/*REXX program to remove duplicate elements (items) in a list. */
|
||||
old= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2'
|
||||
say 'original list:' old
|
||||
say right(words(old),13) ' words in the original list.'; say
|
||||
new= /*start with a clean slate. */
|
||||
$= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2'
|
||||
say 'original list:' $
|
||||
say right(words($),13) ' words in the original list.'; say
|
||||
|
||||
do j=1 for words(old); _=word(old,j) /*process the words in old list. */
|
||||
if wordpos(_,new)==0 then new=new _ /*Doesn't exist? Then add to list*/
|
||||
do j=words($) by -1 to 1; y=word($,j) /*process words in the list, */
|
||||
_=wordpos(y, $, j+1); if _\==0 then $=delword($, _, 1) /*del if dup.*/
|
||||
end /*j*/
|
||||
|
||||
say 'modified list:' space(new)
|
||||
say right(words(new),13) ' words in the modified list.'
|
||||
say 'modified list:' space($)
|
||||
say right(words($),13) ' words in the modified list.'
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
|
|||
|
|
@ -1,28 +1,13 @@
|
|||
/* REXX ************************************************************
|
||||
* 26.11.2012 Walter Pachl
|
||||
* added: show multiple occurrences
|
||||
**********************************************************************/
|
||||
old='2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5',
|
||||
'3 2 0 4.4 2'
|
||||
say 'old list='old
|
||||
say 'words in the old list=' words(old)
|
||||
new=''
|
||||
found.=0
|
||||
count.=0
|
||||
Do While old<>''
|
||||
Parse Var old w old
|
||||
If found.w=0 Then Do
|
||||
new=new w
|
||||
found.w=1
|
||||
End
|
||||
count.w=count.w+1
|
||||
End
|
||||
say 'new list='strip(new)
|
||||
say 'words in the new list=' words(new)
|
||||
Say 'Multiple occurrences:'
|
||||
Say 'occ word'
|
||||
Do While new<>''
|
||||
Parse Var new w new
|
||||
If count.w>1 Then
|
||||
Say right(count.w,3) w
|
||||
End
|
||||
/*REXX program to remove duplicate elements (items) in a list. */
|
||||
old= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2'
|
||||
say 'original list:' old
|
||||
say right(words(old),13) ' words in the original list.'; say
|
||||
new= /*start with a clean slate. */
|
||||
|
||||
do j=1 for words(old); _=word(old,j) /*process the words in old list. */
|
||||
if wordpos(_,new)==0 then new=new _ /*Doesn't exist? Then add to list*/
|
||||
end /*j*/
|
||||
|
||||
say 'modified list:' space(new)
|
||||
say right(words(new),13) ' words in the modified list.'
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/* REXX ************************************************************
|
||||
* 26.11.2012 Walter Pachl
|
||||
* added: show multiple occurrences
|
||||
**********************************************************************/
|
||||
old='2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5',
|
||||
'3 2 0 4.4 2'
|
||||
say 'old list='old
|
||||
say 'words in the old list=' words(old)
|
||||
new=''
|
||||
found.=0
|
||||
count.=0
|
||||
Do While old<>''
|
||||
Parse Var old w old
|
||||
If found.w=0 Then Do
|
||||
new=new w
|
||||
found.w=1
|
||||
End
|
||||
count.w=count.w+1
|
||||
End
|
||||
say 'new list='strip(new)
|
||||
say 'words in the new list=' words(new)
|
||||
Say 'Multiple occurrences:'
|
||||
Say 'occ word'
|
||||
Do While new<>''
|
||||
Parse Var new w new
|
||||
If count.w>1 Then
|
||||
Say right(count.w,3) w
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue