Anadromes: Difference between revisions
Content added Content deleted
Line 484: | Line 484: | ||
│sallets │stellas │ |
│sallets │stellas │ |
||
└────────┴────────┘</syntaxhighlight> |
└────────┴────────┘</syntaxhighlight> |
||
=={{header|jq}}== |
|||
Constructing a very large dictionary (i.e. JSON object) would be time-consuming |
|||
and would require quite a lot of memory, so this implementation takes advantage of jq's `bsearch` for binary search. |
|||
It also confines the search to "words" that begin with a lower-case letter. |
|||
The result is the same listing of 17 words as found elsewhere on this page. |
|||
<pre> |
|||
< words.txt jq -nrR ' |
|||
def rev: explode | reverse | implode; |
|||
[inputs |
|||
| select(length > 6 and |
|||
(.[:1] | . >= "a" and |
|||
. <= "z" and |
|||
. <= .[-1:] )) ] as $words |
|||
| $words[] |
|||
| rev as $reverse |
|||
| select(. < $reverse and ($words | bsearch($reverse) > -1)) |
|||
| . + " <=> " + $reverse |
|||
' |
|||
</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |