Anagram generator: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
||
Line 34: | Line 34: | ||
Implementation: |
Implementation: |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="j">anagen=: {{ |
||
seed=. (tolower y)([-.-.)a.{~97+i.26 |
seed=. (tolower y)([-.-.)a.{~97+i.26 |
||
letters=. ~.seed |
letters=. ~.seed |
||
Line 65: | Line 65: | ||
Examples: |
Examples: |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="j"> 'unixdict.txt' anagen 'Rosettacode' |
||
cetera stood |
cetera stood |
||
coat oersted |
coat oersted |
||
Line 138: | Line 138: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<syntaxhighlight lang=ruby>const unixwords = split(read("unixdict.txt", String) |> lowercase, r"\s+") |
<syntaxhighlight lang="ruby">const unixwords = split(read("unixdict.txt", String) |> lowercase, r"\s+") |
||
function findphrases(anastring::AbstractString, choices, sizelong = 4, n_shortpermitted = 1) |
function findphrases(anastring::AbstractString, choices, sizelong = 4, n_shortpermitted = 1) |
||
Line 210: | Line 210: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Couldn't really think of a better way than just building a dirty great filter list to get rid of the less interesting answers.... |
Couldn't really think of a better way than just building a dirty great filter list to get rid of the less interesting answers.... |
||
<!--<syntaxhighlight lang= |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">bo_ring</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"al"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"alex"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"am"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"an"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"and"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"anent"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ann"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ant"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ar"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ares"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"art"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"at"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ax"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"axle"</span><span style="color: #0000FF;">,</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">bo_ring</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"al"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"alex"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"am"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"an"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"and"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"anent"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ann"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ant"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ar"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ares"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"art"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"at"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"ax"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"axle"</span><span style="color: #0000FF;">,</span> |
||
Line 318: | Line 318: | ||
Using the unixdict.txt word file by default. |
Using the unixdict.txt word file by default. |
||
<syntaxhighlight lang= |
<syntaxhighlight lang="raku" line>unit sub MAIN ($in is copy = '', :$dict = 'unixdict.txt'); |
||
say 'Enter a word or phrase to be anagramed. (Loading dictionary)' unless $in.chars; |
say 'Enter a word or phrase to be anagramed. (Loading dictionary)' unless $in.chars; |
||
Line 382: | Line 382: | ||
Alternatives formed by simply changing the order of the two words have been suppressed. |
Alternatives formed by simply changing the order of the two words have been suppressed. |
||
<syntaxhighlight lang=ecmascript>import "io" for File |
<syntaxhighlight lang="ecmascript">import "io" for File |
||
import "./str" for Str, Char |
import "./str" for Str, Char |
||
import "./perm" for Comb |
import "./perm" for Comb |