Change e letters to i in words: Difference between revisions
Thundergnat (talk | contribs) (→{{header|Raku}}: Add a Raku example) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: minor tidying) |
||
Line 29: | Line 29: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
<lang perl6>my %ei = 'unixdict.txt'.IO.words.grep({ .chars > 5 and /<[ie]>/ }).map: { $_ => .subst('e', 'i', :g) }; |
<lang perl6>my %ei = 'unixdict.txt'.IO.words.grep({ .chars > 5 and /<[ie]>/ }).map: { $_ => .subst('e', 'i', :g) }; |
||
put %ei.grep( *.key.contains: 'e' ).grep({ %ei{.value}:exists }).sort.batch(4)».gist».fmt('%-22s').join: "\n";</lang> |
|||
{{out}} |
{{out}} |
||
<pre>analyses => analysis |
<pre>analyses => analysis atlantes => atlantis bellow => billow breton => briton |
||
clench => clinch |
clench => clinch convect => convict crises => crisis diagnoses => diagnosis |
||
enfant => infant |
enfant => infant enquiry => inquiry frances => francis galatea => galatia |
||
harden => hardin |
harden => hardin heckman => hickman inequity => iniquity inflect => inflict |
||
jacobean => jacobian |
jacobean => jacobian marten => martin module => moduli pegging => pigging |
||
psychoses => psychosis |
psychoses => psychosis rabbet => rabbit sterling => stirling synopses => synopsis |
||
vector => victor |
vector => victor welles => willis</pre> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
Revision as of 12:50, 12 February 2021
- Task
Use the dictionary unixdict.txt
Change letters e to i in words.
If changed word in dictionary show it here on this page.
The length of any word shown should have a length > 5.
Julia
See Alternade_words for the foreachword function. <lang julia>e2i(w, d) = (if 'e' in w s = replace(w, "e" => "i"); haskey(d, s) && return "$w => $s" end; "") foreachword("unixdict.txt", e2i, minlen=6, colwidth=23, numcols=4)
</lang>
- Output:
Word source: unixdict.txt analyses => analysis atlantes => atlantis bellow => billow breton => briton clench => clinch convect => convict crises => crisis diagnoses => diagnosis enfant => infant enquiry => inquiry frances => francis galatea => galatia harden => hardin heckman => hickman inequity => iniquity inflect => inflict jacobean => jacobian marten => martin module => moduli pegging => pigging psychoses => psychosis rabbet => rabbit sterling => stirling synopses => synopsis vector => victor welles => willis
Raku
<lang perl6>my %ei = 'unixdict.txt'.IO.words.grep({ .chars > 5 and /<[ie]>/ }).map: { $_ => .subst('e', 'i', :g) }; put %ei.grep( *.key.contains: 'e' ).grep({ %ei{.value}:exists }).sort.batch(4)».gist».fmt('%-22s').join: "\n";</lang>
- Output:
analyses => analysis atlantes => atlantis bellow => billow breton => briton clench => clinch convect => convict crises => crisis diagnoses => diagnosis enfant => infant enquiry => inquiry frances => francis galatea => galatia harden => hardin heckman => hickman inequity => iniquity inflect => inflict jacobean => jacobian marten => martin module => moduli pegging => pigging psychoses => psychosis rabbet => rabbit sterling => stirling synopses => synopsis vector => victor welles => willis
Ring
<lang ring> load "stdlib.ring"
cStr = read("unixdict.txt") wordList = str2list(cStr) num = 0
see "working..." + nl see "Words are:" + nl
ln = len(wordList) for n = ln to 1 step -1
if len(wordList[n]) < 6 del(wordList,n) ok
next
for n = 1 to len(wordList)
ind = substr(wordList[n],"e") if ind > 0 str = substr(wordList[n],"e","i") indstr = find(wordList,str) if indstr > 0 num = num + 1 see "" + num + ". " + wordList[n] + " => " + str + nl ok ok
next
see "done..." + nl </lang>
- Output:
working... Words are: 1. analyses => analysis 2. atlantes => atlantis 3. bellow => billow 4. breton => briton 5. clench => clinch 6. convect => convict 7. crises => crisis 8. diagnoses => diagnosis 9. enfant => infant 10. enquiry => inquiry 11. frances => francis 12. galatea => galatia 13. harden => hardin 14. heckman => hickman 15. inequity => iniquity 16. inflect => inflict 17. jacobean => jacobian 18. marten => martin 19. module => moduli 20. pegging => pigging 21. psychoses => psychosis 22. rabbet => rabbit 23. sterling => stirling 24. synopses => synopsis 25. vector => victor 26. welles => willis done...