Changeable words: Difference between revisions

no edit summary
(Added XPL0 example.)
No edit summary
Line 236:
51: upperclassman -> upperclassmen
52: upperclassmen -> upperclassman
</pre>
 
=={{header|Julia}}==
<lang julia>function changeable(wordfile, lengthover)
words, results = split(read(wordfile, String)), []
worddict = Dict(w => length(w) for w in words)
for w in words
len = get(worddict, w, 0)
if len <= lengthover
continue
end
alternatives = [w[1:p[1]-1] * p[2] * w[p[1]+1:end] for p in Iterators.product(1:len, 'a':'z')]
for a in alternatives
if a != w && haskey(worddict, a)
push!(results, join(sort([w, a]), " <=> "))
break
end
end
end
println(join(sort(unique(results)), "\n"))
end
 
changeable("unixdict.txt", 11)
</lang>{{out}}
<pre>
aristotelean <=> aristotelian
claustrophobia <=> claustrophobic
committeeman <=> committeemen
committeewoman <=> committeewomen
complementary <=> complimentary
confirmation <=> conformation
congresswoman <=> congresswomen
councilwoman <=> councilwomen
craftsperson <=> draftsperson
eavesdropped <=> eavesdropper
frontiersman <=> frontiersmen
handicraftsman <=> handicraftsmen
incommutable <=> incomputable
installation <=> instillation
kaleidescope <=> kaleidoscope
neuroanatomy <=> neuroanotomy
newspaperman <=> newspapermen
nonagenarian <=> nonogenarian
onomatopoeia <=> onomatopoeic
philanthrope <=> philanthropy
prescription <=> proscription
schizophrenia <=> schizophrenic
shakespearean <=> shakespearian
spectroscope <=> spectroscopy
underclassman <=> underclassmen
upperclassman <=> upperclassmen
</pre>
 
4,111

edits