37 lines
935 B
Text
37 lines
935 B
Text
$ include "seed7_05.s7i";
|
|
include "gethttp.s7i";
|
|
|
|
const func string: reverse (in string: word) is func
|
|
result
|
|
var string: drow is "";
|
|
local
|
|
var integer: index is 0;
|
|
begin
|
|
for index range length(word) downto 1 do
|
|
drow &:= word[index];
|
|
end for;
|
|
end func;
|
|
|
|
const proc: main is func
|
|
local
|
|
var array string: wordList is 0 times "";
|
|
var set of string: words is (set of string).value;
|
|
var string: word is "";
|
|
var string: drow is "";
|
|
var integer: count is 0;
|
|
begin
|
|
wordList := split(lower(getHttp("www.puzzlers.org/pub/wordlists/unixdict.txt")), "\n");
|
|
for word range wordList do
|
|
drow := reverse(word);
|
|
if drow not in words then
|
|
incl(words, word);
|
|
else
|
|
if count < 5 then
|
|
writeln(word <& " " <& drow);
|
|
end if;
|
|
incr(count);
|
|
end if;
|
|
end for;
|
|
writeln;
|
|
writeln("Semordnilap pairs: " <& count);
|
|
end func;
|