RosettaCodeData/Task/Semordnilap/Phix/semordnilap.phix
2016-12-05 23:44:36 +01:00

20 lines
436 B
Text

sequence words={}, semilordnaps={}
object word
constant fn = open("demo\\unixdict.txt","r")
while 1 do
word = trim(gets(fn))
if atom(word) then exit end if
if find(reverse(word),words) then
semilordnaps = append(semilordnaps,word)
end if
words = append(words,word)
end while
close(fn)
?length(semilordnaps)
for i=1 to 5 do
word = semilordnaps[i]
printf(1,"%s - %s\n",{word,reverse(word)})
end for