Anonymous user
Semordnilap: Difference between revisions
Updated to work with Nim 1.4. Replaced "sort" with the easier "sortByIt".
Alextretyak (talk | contribs) (Added 11l) |
(Updated to work with Nim 1.4. Replaced "sort" with the easier "sortByIt".) |
||
Line 2,214:
<lang nim>import strutils, sequtils, sets, algorithm
proc
result = newString(s.len)
for i, c in s:
result[s.high - i] = c
let
words = readFile("unixdict.txt").strip().splitLines()
wordset = words.
revs = words.map(
var pairs = zip(words, revs).filterIt(it[0] < it[1] and it[1] in wordset)
echo "Total number of semordnilaps: ", pairs.len
pairs
echo pairs[
{{out}}
<pre>Total number of semordnilaps: 158
|