Find words which contains more than 3 e vowels: Difference between revisions
Content added Content deleted
(J) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 15: | Line 15: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V aiou = ‘aiou’ // to get round ‘bug in MSVC 2017’[https://developercommunity.visualstudio.com/t/bug-with-operator-in-c/565417] |
||
L(word) File(‘unixdict.txt’).read().split("\n") |
L(word) File(‘unixdict.txt’).read().split("\n") |
||
I !any(word.map(c -> c C :aiou)) & sum(word.map(c -> Int(c == ‘e’))) > 3 |
I !any(word.map(c -> c C :aiou)) & sum(word.map(c -> Int(c == ‘e’))) > 3 |
||
print(word)</ |
print(word)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 42: | Line 42: | ||
=={{header|8080 Assembly}}== |
=={{header|8080 Assembly}}== |
||
< |
<syntaxhighlight lang="8080asm">puts: equ 9 ; CP/M syscall to print a string |
||
fopen: equ 15 ; Open file |
fopen: equ 15 ; Open file |
||
fread: equ 20 ; Read block |
fread: equ 20 ; Read block |
||
Line 105: | Line 105: | ||
jmp 5 |
jmp 5 |
||
emsg: db 'Error$' |
emsg: db 'Error$' |
||
word: equ $</ |
word: equ $</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 130: | Line 130: | ||
=={{header|Action!}}== |
=={{header|Action!}}== |
||
In the following solution the input file [https://gitlab.com/amarok8bit/action-rosetta-code/-/blob/master/source/unixdict.txt unixdict.txt] is loaded from H6 drive. Altirra emulator automatically converts CR/LF character from ASCII into 155 character in ATASCII charset used by Atari 8-bit computer when one from H6-H10 hard drive under DOS 2.5 is used. |
In the following solution the input file [https://gitlab.com/amarok8bit/action-rosetta-code/-/blob/master/source/unixdict.txt unixdict.txt] is loaded from H6 drive. Altirra emulator automatically converts CR/LF character from ASCII into 155 character in ATASCII charset used by Atari 8-bit computer when one from H6-H10 hard drive under DOS 2.5 is used. |
||
< |
<syntaxhighlight lang="action!">BYTE FUNC Count(CHAR ARRAY text CHAR c) |
||
BYTE i,n |
BYTE i,n |
||
Line 171: | Line 171: | ||
FindWords(fname) |
FindWords(fname) |
||
RETURN</ |
RETURN</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Find_words_which_contains_more_than_3_e_vowels.png Screenshot from Atari 8-bit computer] |
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Find_words_which_contains_more_than_3_e_vowels.png Screenshot from Atari 8-bit computer] |
||
Line 180: | Line 180: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">with Ada.Text_Io; |
||
with Ada.Strings.Maps; |
with Ada.Strings.Maps; |
||
with Ada.Strings.Fixed; |
with Ada.Strings.Fixed; |
||
Line 210: | Line 210: | ||
end loop; |
end loop; |
||
Close (File); |
Close (File); |
||
end Find_Three_E;</ |
end Find_Three_E;</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
Interesting to note the word with the most es is "dereference" - a term first used (I believe) in Algol 68... |
Interesting to note the word with the most es is "dereference" - a term first used (I believe) in Algol 68... |
||
< |
<syntaxhighlight lang="algol68"># find words that contain more than 3 es and no other vowels # |
||
# read the list of words and look for suitable words # |
# read the list of words and look for suitable words # |
||
Line 259: | Line 259: | ||
OD; |
OD; |
||
close( input file ) |
close( input file ) |
||
FI</ |
FI</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 282: | Line 282: | ||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
< |
<syntaxhighlight lang="rebol">words: read.lines relative "unixdict.txt" |
||
otherVowels: ["a" "i" "o" "u"] |
otherVowels: ["a" "i" "o" "u"] |
||
containsMoreThan3Es?: function [w][ |
containsMoreThan3Es?: function [w][ |
||
Line 296: | Line 296: | ||
if containsMoreThan3Es? word -> |
if containsMoreThan3Es? word -> |
||
print word |
print word |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 318: | Line 318: | ||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">FileRead, db, % A_Desktop "\unixdict.txt" |
||
vowelsLessE := ["a", "i", "o", "u"] |
vowelsLessE := ["a", "i", "o", "u"] |
||
oRes := [] |
oRes := [] |
||
Line 334: | Line 334: | ||
result .= word "`n" |
result .= word "`n" |
||
} |
} |
||
MsgBox, 262144, , % result</ |
MsgBox, 262144, , % result</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 354: | Line 354: | ||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
< |
<syntaxhighlight lang="awk">/e.*e.*e.*e/ && !/a|i|o|u/ {print}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 378: | Line 378: | ||
=={{header|BCPL}}== |
=={{header|BCPL}}== |
||
< |
<syntaxhighlight lang="bcpl">get "libhdr" |
||
let reads(v) = valof |
let reads(v) = valof |
||
Line 404: | Line 404: | ||
while reads(word) if testword(word) do writef("%S*N",word) |
while reads(word) if testword(word) do writef("%S*N",word) |
||
endread() |
endread() |
||
$)</ |
$)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 424: | Line 424: | ||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
#define SIZE 256 |
#define SIZE 256 |
||
Line 458: | Line 458: | ||
fclose(f); |
fclose(f); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 480: | Line 480: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
< |
<syntaxhighlight lang="cpp">#include <iostream> |
||
#include <fstream> |
#include <fstream> |
||
Line 510: | Line 510: | ||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 532: | Line 532: | ||
=={{header|CLU}}== |
=={{header|CLU}}== |
||
< |
<syntaxhighlight lang="clu">e_word = proc (s: string) returns (bool) |
||
e: int := 0 |
e: int := 0 |
||
for c: char in string$chars(s) do |
for c: char in string$chars(s) do |
||
Line 554: | Line 554: | ||
end |
end |
||
stream$close(dict) |
stream$close(dict) |
||
end start_up</ |
end start_up</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 574: | Line 574: | ||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
< |
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION. |
||
PROGRAM-ID. E-WORDS. |
PROGRAM-ID. E-WORDS. |
||
Line 611: | Line 611: | ||
INSPECT WORD TALLYING OTHER FOR ALL 'u'. |
INSPECT WORD TALLYING OTHER FOR ALL 'u'. |
||
IF E IS GREATER THAN 3 AND OTHER IS EQUAL TO ZERO, |
IF E IS GREATER THAN 3 AND OTHER IS EQUAL TO ZERO, |
||
DISPLAY WORD.</ |
DISPLAY WORD.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 631: | Line 631: | ||
=={{header|Cowgol}}== |
=={{header|Cowgol}}== |
||
< |
<syntaxhighlight lang="cowgol">include "cowgol.coh"; |
||
include "file.coh"; |
include "file.coh"; |
||
Line 679: | Line 679: | ||
end if; |
end if; |
||
ForEachLine(&file, CheckWord);</ |
ForEachLine(&file, CheckWord);</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 702: | Line 702: | ||
=={{header|Draco}}== |
=={{header|Draco}}== |
||
< |
<syntaxhighlight lang="draco">proc eword(*char line) bool: |
||
word e; |
word e; |
||
char c; |
char c; |
||
Line 736: | Line 736: | ||
close(dict) |
close(dict) |
||
corp</ |
corp</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 756: | Line 756: | ||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
< |
<syntaxhighlight lang="fsharp"> |
||
// Words contains more than 3 e vowels. Nigel Galloway: February 11th., 2021. |
// Words contains more than 3 e vowels. Nigel Galloway: February 11th., 2021. |
||
let fN g=let n=Map.ofSeq (Seq.countBy id g) in let fN g=not(n.ContainsKey g) in fN 'a' && fN 'i' && fN 'o' && fN 'u' && not(fN 'e') && n.['e']>3 |
let fN g=let n=Map.ofSeq (Seq.countBy id g) in let fN g=not(n.ContainsKey g) in fN 'a' && fN 'i' && fN 'o' && fN 'u' && not(fN 'e') && n.['e']>3 |
||
seq{use n=System.IO.File.OpenText("unixdict.txt") in while not n.EndOfStream do yield n.ReadLine()}|>Seq.filter fN|>Seq.iter(printfn "%s") |
seq{use n=System.IO.File.OpenText("unixdict.txt") in while not n.EndOfStream do yield n.ReadLine()}|>Seq.filter fN|>Seq.iter(printfn "%s") |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 782: | Line 782: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
< |
<syntaxhighlight lang="factor">USING: formatting io io.encodings.ascii io.files kernel math |
||
sequences ; |
sequences ; |
||
Line 788: | Line 788: | ||
[ [ "aiou" member? ] any? ] reject |
[ [ "aiou" member? ] any? ] reject |
||
[ [ CHAR: e = ] count 3 > ] filter |
[ [ CHAR: e = ] count 3 > ] filter |
||
[ 1 + "%2d: " printf print ] each-index</ |
[ 1 + "%2d: " printf print ] each-index</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 811: | Line 811: | ||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
{{works with|Gforth}} |
{{works with|Gforth}} |
||
< |
<syntaxhighlight lang="forth">: e3 ( addr u -- ? ) |
||
0 { ecount } |
0 { ecount } |
||
0 do |
0 do |
||
Line 847: | Line 847: | ||
main |
main |
||
bye</ |
bye</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 870: | Line 870: | ||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">open "unixdict.txt" for input as #1 |
||
dim as string s, c |
dim as string s, c |
||
Line 884: | Line 884: | ||
next i |
next i |
||
if e>3 then print s |
if e>3 then print s |
||
wend</ |
wend</syntaxhighlight> |
||
{{out}}<pre> |
{{out}}<pre> |
||
belvedere |
belvedere |
||
Line 905: | Line 905: | ||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
< |
<syntaxhighlight lang="frink">for word = lines["https://web.archive.org/web/20180611003215if_/http://www.puzzlers.org:80/pub/wordlists/unixdict.txt"] |
||
{ |
{ |
||
d = countToDict[charList[word]] |
d = countToDict[charList[word]] |
||
if d.get["a",0] == 0 and d.get["e",0] > 3 and d.get["i",0] == 0 and d.get["o",0] == 0 and d.get["u",0] == 0 |
if d.get["a",0] == 0 and d.get["e",0] > 3 and d.get["i",0] == 0 and d.get["o",0] == 0 and d.get["u",0] == 0 |
||
println[word] |
println[word] |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 932: | Line 932: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">package main |
||
import ( |
import ( |
||
Line 976: | Line 976: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 999: | Line 999: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import System.IO |
||
main = withFile "unixdict.txt" ReadMode $ \h -> do |
main = withFile "unixdict.txt" ReadMode $ \h -> do |
||
Line 1,005: | Line 1,005: | ||
putStrLn $ unlines $ filter valid words |
putStrLn $ unlines $ filter valid words |
||
valid w = not (any (`elem` "aiou") w) && length (filter (=='e') w) > 3</ |
valid w = not (any (`elem` "aiou") w) && length (filter (=='e') w) > 3</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,028: | Line 1,028: | ||
=={{header|J}}== |
=={{header|J}}== |
||
< |
<syntaxhighlight lang="j"> >(#~ (0 4 0 0 0 -: 4 <. +/ .(=/)&'aeiou')@>) cutLF fread'unixdict.txt' |
||
belvedere |
belvedere |
||
dereference |
dereference |
||
Line 1,044: | Line 1,044: | ||
seventeenth |
seventeenth |
||
telemeter |
telemeter |
||
tennessee</ |
tennessee</syntaxhighlight> |
||
(Also possible to do this with regular expressions, but this works. Here, we counted how many times each vowel occurred, limited the maximum count to 4, and checked the resulting signature.) |
(Also possible to do this with regular expressions, but this works. Here, we counted how many times each vowel occurred, limited the maximum count to 4, and checked the resulting signature.) |
||
Line 1,053: | Line 1,053: | ||
===Using regular expressions=== |
===Using regular expressions=== |
||
< |
<syntaxhighlight lang="jq">inputs |
||
| select(test("[aiou]")|not) |
| select(test("[aiou]")|not) |
||
| select(test("e.*e.*e.*e"))</ |
| select(test("e.*e.*e.*e"))</syntaxhighlight> |
||
===Regex-free solution=== |
===Regex-free solution=== |
||
< |
<syntaxhighlight lang="jq">def count(s): reduce s as $x (null; .+1); |
||
("aiou" | explode) as $disallow |
("aiou" | explode) as $disallow |
||
Line 1,066: | Line 1,066: | ||
count(.[] | select(. == 101)) > 3) # "e" is 101 |
count(.[] | select(. == 101)) > 3) # "e" is 101 |
||
| $word |
| $word |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Invocation example: jq -nrR program.jq unixdict.txt |
Invocation example: jq -nrR program.jq unixdict.txt |
||
Line 1,090: | Line 1,090: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
See [[Alternade_words#Julia]] for the foreachword function. |
See [[Alternade_words#Julia]] for the foreachword function. |
||
< |
<syntaxhighlight lang="julia">ecount(word) = count(x -> x == 'e', word) |
||
vowelcount(word) = count(x -> x in ['a', 'e', 'i', 'o', 'u'], word) |
vowelcount(word) = count(x -> x in ['a', 'e', 'i', 'o', 'u'], word) |
||
onlyevowelsmorethan3(word, _) = begin n, m = vowelcount(word), ecount(word); n == m && m > 3 ? word : "" end |
onlyevowelsmorethan3(word, _) = begin n, m = vowelcount(word), ecount(word); n == m && m > 3 ? word : "" end |
||
foreachword("unixdict.txt", onlyevowelsmorethan3, colwidth=15, numcols=8) |
foreachword("unixdict.txt", onlyevowelsmorethan3, colwidth=15, numcols=8) |
||
</ |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
belvedere dereference elsewhere erlenmeyer evergreen everywhere exegete freewheel |
belvedere dereference elsewhere erlenmeyer evergreen everywhere exegete freewheel |
||
Line 1,102: | Line 1,102: | ||
=={{header|Ksh}}== |
=={{header|Ksh}}== |
||
< |
<syntaxhighlight lang="ksh"> |
||
#!/bin/ksh |
#!/bin/ksh |
||
Line 1,138: | Line 1,138: | ||
(( $(_countch "$REPLY" "e") >= MINE )) && print $REPLY |
(( $(_countch "$REPLY" "e") >= MINE )) && print $REPLY |
||
done < ${dictionary} |
done < ${dictionary} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}}<pre> |
{{out}}<pre> |
||
belvedere |
belvedere |
||
Line 1,158: | Line 1,158: | ||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">vowels = Characters["euioa"]; |
||
dict = Once[Import["https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt"]]; |
dict = Once[Import["https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt"]]; |
||
dict //= StringSplit[#, "\n"] &; |
dict //= StringSplit[#, "\n"] &; |
||
Line 1,164: | Line 1,164: | ||
dict //= Select[Last /* Count["e"] /* GreaterThan[3]]; |
dict //= Select[Last /* Count["e"] /* GreaterThan[3]]; |
||
dict //= Select[Last /* Apply[SameQ]]; |
dict //= Select[Last /* Apply[SameQ]]; |
||
dict[[All, 1]]</ |
dict[[All, 1]]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>{belvedere, dereference, elsewhere, erlenmeyer, evergreen, everywhere, exegete, freewheel, nevertheless, persevere, preference, referee, seventeen, seventeenth, telemeter, tennessee}</pre> |
<pre>{belvedere, dereference, elsewhere, erlenmeyer, evergreen, everywhere, exegete, freewheel, nevertheless, persevere, preference, referee, seventeen, seventeenth, telemeter, tennessee}</pre> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim">import strutils |
||
const NonEVowels = ['a', 'i', 'o', 'u'] |
const NonEVowels = ['a', 'i', 'o', 'u'] |
||
Line 1,180: | Line 1,180: | ||
if vowel in word: break checkWord |
if vowel in word: break checkWord |
||
inc count |
inc count |
||
stdout.write word.align(14), if count mod 4 == 0: '\n' else: ' '</ |
stdout.write word.align(14), if count mod 4 == 0: '\n' else: ' '</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,190: | Line 1,190: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{works with|Turbo Pascal}} |
{{works with|Turbo Pascal}} |
||
< |
<syntaxhighlight lang="pascal">program EWords; |
||
var |
var |
||
FileVar: Text; |
FileVar: Text; |
||
Line 1,217: | Line 1,217: | ||
end |
end |
||
end |
end |
||
end.</ |
end.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,239: | Line 1,239: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">#!/usr/bin/perl |
||
use strict; # https://rosettacode.org/wiki/Find_words_which_contains_more_than_3_e_vowels |
use strict; # https://rosettacode.org/wiki/Find_words_which_contains_more_than_3_e_vowels |
||
Line 1,245: | Line 1,245: | ||
@ARGV = 'unixdict.txt'; |
@ARGV = 'unixdict.txt'; |
||
tr/e// > 3 and tr/aiou// == 0 and print while <>;</ |
tr/e// > 3 and tr/aiou// == 0 and print while <>;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
belvedere |
belvedere |
||
Line 1,265: | Line 1,265: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--< |
<!--<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;">function</span> <span style="color: #000000;">note</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">word</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">find_any</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"aiou"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">find_all</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'e'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">))></span><span style="color: #000000;">3</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span> |
<span style="color: #008080;">function</span> <span style="color: #000000;">note</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">word</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">return</span> <span style="color: #7060A8;">find_any</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"aiou"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">find_all</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'e'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">))></span><span style="color: #000000;">3</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span> |
||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">notes</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">unix_dict</span><span style="color: #0000FF;">(),</span><span style="color: #000000;">note</span><span style="color: #0000FF;">)</span> |
<span style="color: #004080;">sequence</span> <span style="color: #000000;">notes</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">filter</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">unix_dict</span><span style="color: #0000FF;">(),</span><span style="color: #000000;">note</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d words: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">notes</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">notes</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">))})</span> |
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d words: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">notes</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">notes</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">))})</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,277: | Line 1,277: | ||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
< |
<syntaxhighlight lang="pli">moreThanThreeEs: procedure options(main); |
||
declare dict file; |
declare dict file; |
||
open file(dict) title('unixdict.txt'); |
open file(dict) title('unixdict.txt'); |
||
Line 1,298: | Line 1,298: | ||
close file(dict); |
close file(dict); |
||
end moreThanThreeEs;</ |
end moreThanThreeEs;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 1,318: | Line 1,318: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<syntaxhighlight lang="python">with open('unixdict.txt', 'rt') as f: |
||
for line in f.readlines(): |
for line in f.readlines(): |
||
if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3: |
if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3: |
||
print(line.strip())</ |
print(line.strip())</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,344: | Line 1,344: | ||
=={{header|R}}== |
=={{header|R}}== |
||
Adapting this from https://rosettacode.org/wiki/Find_words_which_contains_all_the_vowels#R is trivial. |
Adapting this from https://rosettacode.org/wiki/Find_words_which_contains_all_the_vowels#R is trivial. |
||
< |
<syntaxhighlight lang="rsplus">dict <- scan("https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt", what = character()) |
||
#The following line is equivalent to sapply(c("a", "i", "o", "u"), function(x) stringr::str_count(dict, x)) |
#The following line is equivalent to sapply(c("a", "i", "o", "u"), function(x) stringr::str_count(dict, x)) |
||
#As with all things with strings in R, life is easier with stringr or stringi. |
#As with all things with strings in R, life is easier with stringr or stringi. |
||
notEVowelCount <- sapply(c("a", "i", "o", "u"), function(x) lengths(regmatches(dict, gregexec(x, dict)))) |
notEVowelCount <- sapply(c("a", "i", "o", "u"), function(x) lengths(regmatches(dict, gregexec(x, dict)))) |
||
eCount <- lengths(regmatches(dict, gregexec("e", dict))) |
eCount <- lengths(regmatches(dict, gregexec("e", dict))) |
||
dict[apply(notEVowelCount, MARGIN = 1, function(x) all(x < 1)) & eCount > 3]</ |
dict[apply(notEVowelCount, MARGIN = 1, function(x) all(x < 1)) & eCount > 3]</syntaxhighlight> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
;; probably not the best name, but matches the name of the task |
;; probably not the best name, but matches the name of the task |
||
Line 1,371: | Line 1,371: | ||
(module+ main |
(module+ main |
||
qualifying-words)</ |
qualifying-words)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,380: | Line 1,380: | ||
Hardly even worth saving as a script file; an easily entered one-liner. |
Hardly even worth saving as a script file; an easily entered one-liner. |
||
<lang |
<syntaxhighlight lang="raku" line>.say for "unixdict.txt".IO.lines.grep: { !/<[aiou]>/ and /e.*e.*e.*e/ };</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,403: | Line 1,403: | ||
In an attempt to be a little less useless, here's an alternate script that allows you to specify a vowel, the minimum count to search for, and the file to search. Counts base vowels case, and combining accent insensitive; works with ''any'' text file, not just word lists. Defaults to finding words with at least 4 'e's in unixdict.txt. Default output is same as above. |
In an attempt to be a little less useless, here's an alternate script that allows you to specify a vowel, the minimum count to search for, and the file to search. Counts base vowels case, and combining accent insensitive; works with ''any'' text file, not just word lists. Defaults to finding words with at least 4 'e's in unixdict.txt. Default output is same as above. |
||
<lang |
<syntaxhighlight lang="raku" line>unit sub MAIN ($vowel = 'e', $min = 4, $file = 'unixdict.txt'); |
||
.say for squish sort |
.say for squish sort |
||
( $file.IO.slurp.words.grep: { ((my $b = .lc.samemark(' ').comb.Bag){$vowel} >= $min) && $b<a e i o u>.sum == $b{$vowel} } )\ |
( $file.IO.slurp.words.grep: { ((my $b = .lc.samemark(' ').comb.Bag){$vowel} >= $min) && $b<a e i o u>.sum == $b{$vowel} } )\ |
||
».subst(/<[":;,.?!_\[\]]>/, '', :g);</ |
».subst(/<[":;,.?!_\[\]]>/, '', :g);</syntaxhighlight> |
||
How about: find words with at least 4 'a's in the [https://github.com/thundergnat/rc-run/blob/master/rc/resources/lemiz.txt Les Misérables file] used for the [[Word frequency]] task? |
How about: find words with at least 4 'a's in the [https://github.com/thundergnat/rc-run/blob/master/rc/resources/lemiz.txt Les Misérables file] used for the [[Word frequency]] task? |
||
Line 1,419: | Line 1,419: | ||
=={{header|Red}}== |
=={{header|Red}}== |
||
< |
<syntaxhighlight lang="rebol">Red[] |
||
words: read/lines %unixdict.txt |
words: read/lines %unixdict.txt |
||
Line 1,432: | Line 1,432: | ||
] |
] |
||
if all [retain e's > 3] [print word] |
if all [retain e's > 3] [print word] |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,458: | Line 1,458: | ||
It also allows the vowel to be specified, and also the minimum number of the specific vowels to be specified on the command line (CL) as well as the dictionary file identifier. |
It also allows the vowel to be specified, and also the minimum number of the specific vowels to be specified on the command line (CL) as well as the dictionary file identifier. |
||
< |
<syntaxhighlight lang="rexx">/*REXX pgm finds words (within an identified dict.) which contain more than three "e"s.*/ |
||
parse arg char many iFID . /*obtain optional arguments from the CL*/ |
parse arg char many iFID . /*obtain optional arguments from the CL*/ |
||
if char=='' | char=="," then char= 'e' /*Not specified? Then use the default.*/ |
if char=='' | char=="," then char= 'e' /*Not specified? Then use the default.*/ |
||
Line 1,482: | Line 1,482: | ||
end /*j*/ |
end /*j*/ |
||
/*stick a fork in it, we're all done. */ |
/*stick a fork in it, we're all done. */ |
||
say copies('─', 30) finds " words found having " many ' ' copies(char, many) " letters."</ |
say copies('─', 30) finds " words found having " many ' ' copies(char, many) " letters."</syntaxhighlight> |
||
{{out|output|text= when using the default inputs:}} |
{{out|output|text= when using the default inputs:}} |
||
<pre> |
<pre> |
||
Line 1,506: | Line 1,506: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
load "stdlib.ring" |
load "stdlib.ring" |
||
Line 1,547: | Line 1,547: | ||
see "done..." + nl |
see "done..." + nl |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 1,572: | Line 1,572: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">File.new("unixdict.txt").each do |word| |
||
puts word if word.count("e") > 3 && word.count("aiou") == 0 |
puts word if word.count("e") > 3 && word.count("aiou") == 0 |
||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>belvedere |
<pre>belvedere |
||
Line 1,595: | Line 1,595: | ||
</pre> |
</pre> |
||
=={{header|Snobol}}== |
=={{header|Snobol}}== |
||
< |
<syntaxhighlight lang="snobol"> input(.words, 1,, 'unixdict.txt') :s(line) |
||
output = 'Error!' :(end) |
output = 'Error!' :(end) |
||
line word = words :f(end) |
line word = words :f(end) |
||
Line 1,601: | Line 1,601: | ||
word 'e' arb 'e' arb 'e' arb 'e' :f(line) |
word 'e' arb 'e' arb 'e' arb 'e' :f(line) |
||
output = word :(line) |
output = word :(line) |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,623: | Line 1,623: | ||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">import Foundation |
||
func e3(_ word: String) -> Bool { |
func e3(_ word: String) -> Bool { |
||
Line 1,648: | Line 1,648: | ||
} catch { |
} catch { |
||
print(error.localizedDescription) |
print(error.localizedDescription) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,672: | Line 1,672: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
< |
<syntaxhighlight lang="ecmascript">import "io" for File |
||
import "/fmt" for Fmt |
import "/fmt" for Fmt |
||
Line 1,684: | Line 1,684: | ||
Fmt.print("$2d: $s", count, word) |
Fmt.print("$2d: $s", count, word) |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,707: | Line 1,707: | ||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
< |
<syntaxhighlight lang="xpl0">string 0; \Use zero-terminated strings |
||
int I, Ch, Len; |
int I, Ch, Len; |
||
char Word(100); \(longest word in unixdict.txt is 22 chars) |
char Word(100); \(longest word in unixdict.txt is 22 chars) |
||
Line 1,740: | Line 1,740: | ||
if Es then [Text(0, Word); CrLf(0)]; |
if Es then [Text(0, Word); CrLf(0)]; |
||
until Ch = EOF; |
until Ch = EOF; |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |