/* NetRexx */ options replace format comments java crossref symbols nobinary -- Note: Task requirement is to process "arrays". The following converts arrays into simple lists of words: -- Putting the resulting list back into an array is left as an exercise for the reader. a1 = [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] a2 = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] a3 = ['Now', 'is', 'the', 'time', 'for', 'all', 'good', 'men', 'to', 'come', 'to', 'the', 'aid', 'of', 'the', 'party.'] x = 0 lists = '' x = x + 1; lists[0] = x; lists[x] = array2wordlist(a1) x = x + 1; lists[0] = x; lists[x] = array2wordlist(a2) x = x + 1; lists[0] = x; lists[x] = array2wordlist(a3) loop ix = 1 to lists[0] nodups_list = remove_dups(lists[ix]) say ix.right(4)':' lists[ix] say ''.right(4)':' nodups_list say end ix return -- ============================================================================= method remove_dups(list) public static newlist = '' nodups = '0' loop w_ = 1 to list.words() ix = list.word(w_) nodups[ix] = nodups[ix] + 1 -- we can even collect a count of dups if we want end w_ loop k_ over nodups newlist = newlist k_ end k_ return newlist.space -- ============================================================================= method array2wordlist(ra = Rexx[]) public static wordlist = '' loop r_ over ra wordlist = wordlist r_ end r_ return wordlist.space