Changeable words: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: used more idiomatic code.) |
|||
Line 710: | Line 710: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
See [[Alternade_words#Julia] for the foreachword function. |
|||
After finding for example "are <=> art", we do not also list the redundant "art <=> are" below. |
|||
<lang julia> |
<lang julia>const alts = Set{String}() |
||
function ischangeable(w, d) |
|||
words, results = split(read(wordfile, String)), [] |
|||
⚫ | |||
worddict = Dict(w => length(w) for w in words) |
|||
for |
for a in alternatives |
||
if a != w && haskey(d, a) |
|||
result = join(sort([w, a]), " <=> ") |
|||
if !(result in alts) |
|||
push!(alts, result) |
|||
⚫ | |||
⚫ | |||
for a in alternatives |
|||
if a != w && haskey(worddict, a) |
|||
push!(results, join(sort([w, a]), " <=> ")) |
|||
⚫ | |||
end |
end |
||
end |
end |
||
end |
end |
||
return "" |
|||
println(join(sort(unique(results)), "\n")) |
|||
end |
end |
||
foreachword("unixdict.txt", ischangeable, minlen = 12, colwidth=40, numcols=2) |
|||
</lang>{{out}} |
</lang>{{out}} |
||
<pre> |
<pre> |
||
Word source: unixdict.txt |
|||
⚫ | |||
claustrophobia <=> claustrophobic |
|||
⚫ | |||
committeeman <=> committeemen |
|||
committeewoman <=> committeewomen |
committeeman <=> committeemen committeewoman <=> committeewomen |
||
complementary <=> complimentary |
complementary <=> complimentary confirmation <=> conformation |
||
⚫ | |||
confirmation <=> conformation |
|||
⚫ | |||
⚫ | |||
⚫ | |||
councilwoman <=> councilwomen |
|||
⚫ | |||
⚫ | |||
⚫ | |||
eavesdropped <=> eavesdropper |
|||
⚫ | |||
⚫ | |||
⚫ | |||
handicraftsman <=> handicraftsmen |
|||
⚫ | |||
⚫ | |||
⚫ | |||
installation <=> instillation |
|||
⚫ | |||
⚫ | |||
neuroanatomy <=> neuroanotomy |
|||
⚫ | |||
nonagenarian <=> nonogenarian |
|||
⚫ | |||
philanthrope <=> philanthropy |
|||
prescription <=> proscription |
|||
⚫ | |||
⚫ | |||
spectroscope <=> spectroscopy |
|||
⚫ | |||
upperclassman <=> upperclassmen |
|||
</pre> |
</pre> |
||