Text completion: Difference between revisions
m
→{{header|Phix}}: flexible args
m (→{{header|Phix}}: "not" collection!) |
m (→{{header|Phix}}: flexible args) |
||
Line 143:
<lang Phix>string word = "complition"
sequence words = get_text(join_path({"demo","unixdict.txt"}),GT_LF_STRIPPED)
function lt(string w, integer n) return levenshtein(w,word)=n end function
--function lt(string w, sequence nw) -- alt...▼
-- {integer n, string word} = nw -- ...""▼
for n=1 to 4 do
printf(1,"Words at Levenshtein distance of %d (%g%% similarity) from \"%s\": \n%s\n",
{n,100-round(100*n/length(word)),word,join_by(filter(words,lt,n),1,6)})
-- ..."" {n,100-round(100*n/length(word)),word,join_by(filter(words,lt,{n,word}),1,6)})▼
end for</lang>
Note the parameters of the filter routine lt() can be quite flexible, for instance you could instead do this (and get the same results)
...
{{out}}
<pre>
|