26 lines
853 B
Text
26 lines
853 B
Text
Module semordnilaps {
|
|
Document d$
|
|
Load.Doc d$, "unixdict.txt"
|
|
Inventory MyDict, Result
|
|
Function s$(a$) {
|
|
m$=a$:k=Len(a$):for i=1 to k {insert i, 1 m$=mid$(a$, k, 1):k--} : =m$
|
|
}
|
|
L=Doc.Par(d$)
|
|
m=Paragraph(d$, 0)
|
|
If not Forward(d$,m) then exit
|
|
i=1
|
|
While m {
|
|
word$=Paragraph$(d$,(m))
|
|
Print Over $(0, 10), str$(i/L,"##0.00%"), Len(Result) : i++
|
|
If Exist(MyDict, word$) then { if Exist(Result, word$) Then exit
|
|
Append Result, word$
|
|
} Else.if len(word$)>1 Then p$=s$(word$):if p$<>word$ Then Append MyDict, p$
|
|
}
|
|
Print
|
|
Print "Semordnilap pairs: ";Len(Result)
|
|
For i=0 to len(Result)-1 step len(Result) div 5 {
|
|
p$=Eval$(Result, i)
|
|
Print s$(p$);"/";p$
|
|
}
|
|
}
|
|
semordnilaps
|