/* NetRexx */ options replace format comments java crossref symbols nobinary /* REXX *************************************************************** * 07.09.2012 Walter Pachl **********************************************************************/ fid = 'unixdict.txt' /* the test dictionary */ ifi = File(fid) ifr = BufferedReader(FileReader(ifi)) have = '' /* words encountered */ pi = 0 /* number of palindromes */ loop label j_ forever /* as long there is input */ line = ifr.readLine /* read a line (String) */ if line = null then leave j_ /* NULL indicates EOF */ w = Rexx(line) /* each line contains 1 word */ If w > '' Then Do /* not a blank line */ r = w.reverse /* reverse it */ If have[r] > '' Then Do /* was already encountered */ pi = pi + 1 /* increment number of pal's */ If pi <= 5 Then /* the first 5 are listed */ Say have[r] w End have[w] = w /* remember the word */ End end j_ ifr.close Say pi 'words in' fid 'have a palindrome' /* total number found */ return