View previous topic :: View next topic
|
Author |
Message |
ravi.bollineni
New User
Joined: 28 Jun 2006 Posts: 8
|
|
|
|
Hi All,
I have verified the forum for this but i didn't find any valuable information.
But i want to do the following.
My program creating a Stem output. But it contains duplicate elements. I want to remove duplicate elements from my Stem output.
For the above, thoughts right now are first perform a sorting(Bubble or selection) methodology after that write a code to remove the duplicate elements.
Am i going in correct way...or any other functions exist in REXX Language to remove the duplicate elements in STEM.
If you have sample code for this Please share with me.
Always Thanking You,
Ravi. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
The is no REXX function to do that.
You can write the whole stem into a file (EXECIO DISKW), then use that file as an input to SORT with SUM=NONE (or something like that to remove the duplicates), then read the output back into a stem. |
|
Back to top |
|
|
mike53
New User
Joined: 09 Jul 2006 Posts: 3 Location: UK
|
|
|
|
Maybe it would be possible to re-design your REXX program so that you don't get the duplicate variables in the first place? It's difficult to comment without seeing the actual code, but remember that the index of a stem variable does not have to be a number - it can be anything. In effect the stem variable acts a bit like a keyed file, with the index as a key. Keep that in mind and take a fresh look at your code. Just an idea! |
|
Back to top |
|
|
ravi.bollineni
New User
Joined: 28 Jun 2006 Posts: 8
|
|
|
|
Thanks a lot for all of you.
Actually i wrote the code in REXX program and i don't want write it to another file and give the same as input to the SORT JCL.
I need to do the requirement in REXX only. So am following like whatever i mentioned.
Anyway thanks for all of you.
Always Thanking You,
Ravi. |
|
Back to top |
|
|
nuck
New User
Joined: 09 Dec 2005 Posts: 33
|
|
|
|
ok, so this thread is probably dead, but I'll add my $0.02...
to make sure duplicate (contents?) in a stem don't occur, before adding the new value into the stem, do a search on the existing contents.
content_found='N'
do j = 1 to content_count
if this_content = stem_content.j
then do
content_found= 'Y'
j = content_count +1
end
end
if content_found = 'N'
then do
content_count=content_count+1
stem.content.content.count = this_content
end
no? |
|
Back to top |
|
|
Redrose Currently Banned New User
Joined: 06 Mar 2006 Posts: 19
|
|
|
|
Hi friends ,
We can eliminate duplicates from the Stem variable as below,
Steps:
1. If InStem's 1'st element, Move the element to OutStem
2. Else check all OutStem elements for the current InStem element
3. If found, Iterate to next InStem element
4. Else add InStem's element to OutStem
**********************Code-Starts-Here************************
/* REXX code to remove duplicates from Stem
Input Stem - InStem.
Output Stem - OutStem.
Array Counters - I, J, K */
J = 1
DO I = 1 TO InStem.0
IF I = 1 THEN
OutStem.I = InStem.I
ELSE
DO K = 1 TO J
IF (InStem.I ?= OutStem.K) & (K = J) THEN
DO
J = J + 1
OutStem.J = InStem.I
END
ELSE
DO
IF (InStem.I == OutStem.K) THEN
ITERATE I
END
END
END
OutStem.0 = J
**********************Code-Ends-Here*************************
Hope it helps,
Ur's
Ramanan R
-------------------------------------------------------------------------------------
Winners Don't Do Different Things, They Do Things Differently
- Shiv Kehra
------------------------------------------------------------------------------------- |
|
Back to top |
|
|
srajendran
New User
Joined: 25 Sep 2006 Posts: 24
|
|
|
|
To do this in An easy way .....
Just Concatenate the stem variables separated by spaces and before concatnating check for the WORDPOS of the current variable....If the WORDPOS is greater than 0, then it would be a duplicate...If not concatenate the string....
Do this for the whole stem n when its done then take up the words into the stem again.... |
|
Back to top |
|
|
|