Changeable words: Difference between revisions
→{{header|jq}}: faster
(→{{header|jq}}: faster) |
|||
Line 874:
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
<lang jq># Emit a stream of words "greater than" the input word that differ by just one character.▼
▲# Emit a stream of words "greater than" the input word that differ by just one character.
▲def changeable_to($dict; $alphas):
. as $w
| range(0;length) as $i
| (.[$i:$i+1]|explode[]) as $j
| .[:$i] + $alphas[] + .[$i+1:]
| select(
INDEX( inputs; . )
| . as $dict
| keys_unsorted[] # or keys[] for gojq
▲| [range(97;123) | [.] | implode] as $alphas
| select(length>11)
| . as $w
| [changeable_to($dict
| "\($w) <=> \(.)"</lang>
Invocation: jq -n -rR -f changeable-words.jq unixdict.txt
{{out}}
Line 922 ⟶ 920:
upperclassman <=> upperclassmen
</pre>
=={{header|Julia}}==
|