3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
6 # Simple Rosettacode task for the detection of semordnilaps in a text file
8 # SEE: http://rosettacode.org/wiki/Semordnilap
12 print
"Usage: ./semordnilap file"
16 var filename
= args
[0]
17 var words
= new HashSet[String]
19 for i
in filename
.to_path
.each_line
do words
.add i
.trim
21 var semordnilaps
= new HashSet[String]
22 var pairs
= new HashMap[String, String]
26 if i
!= revi
and words
.has
(revi
) and not semordnilaps
.has
(i
) then
33 print
"Found {pairs.length} semordnilaps in {args[0]}"
34 var it
= pairs
.iterator
36 print
"{it.key}: {it.item}"