Find words which contains more than 3 e vowels: Difference between revisions

m
(Add COBOL)
m (→‎{{header|Wren}}: Minor tidy)
 
(21 intermediate revisions by 15 users not shown)
Line 15:
{{trans|Python}}
 
<langsyntaxhighlight 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")
I !any(word.map(c -> c C :aiou)) & sum(word.map(c -> Int(c == ‘e’))) > 3
print(word)</langsyntaxhighlight>
 
{{out}}
Line 42:
 
=={{header|8080 Assembly}}==
<langsyntaxhighlight lang="8080asm">puts: equ 9 ; CP/M syscall to print a string
fopen: equ 15 ; Open file
fread: equ 20 ; Read block
Line 105:
jmp 5
emsg: db 'Error$'
word: equ $</langsyntaxhighlight>
 
{{out}}
Line 130:
=={{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.
<langsyntaxhighlight Actionlang="action!">BYTE FUNC Count(CHAR ARRAY text CHAR c)
BYTE i,n
 
Line 171:
 
FindWords(fname)
RETURN</langsyntaxhighlight>
{{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]
Line 180:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io;
with Ada.Strings.Maps;
with Ada.Strings.Fixed;
Line 210:
end loop;
Close (File);
end Find_Three_E;</langsyntaxhighlight>
 
=={{header|ALGOL 68}}==
Interesting to note the word with the most es is "dereference" - a term first used (I believe) in Algol 68...
<langsyntaxhighlight lang="algol68"># find words that contain more than 3 es and no other vowels #
 
# read the list of words and look for suitable words #
Line 259:
OD;
close( input file )
FI</langsyntaxhighlight>
{{out}}
<pre>
Line 279:
16: tennessee (4)
</pre>
 
=={{header|AppleScript}}==
<syntaxhighlight lang="applescript">on findWordsWhichContainsMoreThan3EVowels()
script o
property wrds : words of ¬
(read file ((path to desktop as text) & "unixdict.txt") as «class utf8»)
end script
set output to {}
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "e"
repeat with thisWord in o's wrds
set thisWord to thisWord's contents
if (((count thisWord's text items) > 4) and not ¬
((thisWord contains "a") or (thisWord contains "i") or ¬
(thisWord contains "o") or (thisWord contains "u"))) then
set end of output to thisWord
end if
end repeat
set AppleScript's text item delimiters to linefeed
set output to output as text
set AppleScript's text item delimiters to astid
return output
end findWordsWhichContainsMoreThan3EVowels
 
findWordsWhichContainsMoreThan3EVowels()</syntaxhighlight>
 
{{output}}
<syntaxhighlight lang="applescript">"belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee"</syntaxhighlight>
 
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">words: read.lines relative "unixdict.txt"
otherVowels: ["a" "i" "o" "u"]
containsMoreThan3Es?: function [w][
Line 296 ⟶ 339:
if containsMoreThan3Es? word ->
print word
]</langsyntaxhighlight>
 
{{out}}
Line 318 ⟶ 361:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">FileRead, db, % A_Desktop "\unixdict.txt"
vowelsLessE := ["a", "i", "o", "u"]
oRes := []
Line 334 ⟶ 377:
result .= word "`n"
}
MsgBox, 262144, , % result</langsyntaxhighlight>
{{out}}
<pre>belvedere
Line 354 ⟶ 397:
 
=={{header|AWK}}==
<langsyntaxhighlight AWKlang="awk">/e.*e.*e.*e/ && !/a|i|o|u/ {print}</langsyntaxhighlight>
 
{{out}}
Line 378 ⟶ 421:
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let reads(v) = valof
Line 404 ⟶ 447:
while reads(word) if testword(word) do writef("%S*N",word)
endread()
$)</langsyntaxhighlight>
{{out}}
<pre>belvedere
Line 424 ⟶ 467:
 
=={{header|C}}==
<langsyntaxhighlight lang="c">#include <stdio.h>
#define SIZE 256
 
Line 458 ⟶ 501:
fclose(f);
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 480 ⟶ 523:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <fstream>
 
Line 510 ⟶ 553:
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 532 ⟶ 575:
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">e_word = proc (s: string) returns (bool)
e: int := 0
for c: char in string$chars(s) do
Line 554 ⟶ 597:
end
stream$close(dict)
end start_up</langsyntaxhighlight>
{{out}}
<pre>belvedere
Line 574 ⟶ 617:
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. E-WORDS.
Line 611 ⟶ 654:
INSPECT WORD TALLYING OTHER FOR ALL 'u'.
IF E IS GREATER THAN 3 AND OTHER IS EQUAL TO ZERO,
DISPLAY WORD.</langsyntaxhighlight>
{{out}}
<pre>belvedere
Line 631 ⟶ 674:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
include "file.coh";
 
Line 679 ⟶ 722:
end if;
 
ForEachLine(&file, CheckWord);</langsyntaxhighlight>
 
{{out}}
Line 700 ⟶ 743:
tennessee
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|Classes,StdCtrls,SysUtils}}
This program makes extensive use of the standard Delphi TStringList component. It holds the dictionary, which is preloaded. It capture the E-Vowel-only information in a TStringList and uses it to display the words.
 
<syntaxhighlight lang="Delphi">
 
var Dict: TStringList; {List holds dictionary}
 
function HasEVowels(S: string): boolean;
{Test if string has exclusively E-Vowels and no "a,i,o,u"}
var I,ECount: integer;
begin
Result:=False;
ECount:=0;
for I:=1 to Length(S) do
begin
if S[I] in ['a','i','o','u'] then exit;
if S[I]='e' then Inc(ECount);
end;
Result:=ECount>3;
end;
 
 
procedure ShowEVowels(Memo: TMemo);
{Show words in dictionary that only}
{have e-vowels and have at least three}
var I: integer;
var SL: TStringList;
var S: string;
begin
SL:=TStringList.Create;
try
{Make list of words with least three E-vowels}
for I:=0 to Dict.Count-1 do
if HasEVowels(Dict[I]) then SL.Add(Dict[I]);
{Display all the words found}
S:='Found: '+IntToStr(SL.Count)+#$0D#$0A;
for I:=0 to SL.Count-1 do
begin
S:=S+Format('%-23s',[SL[I]]);
if (I mod 4)=3 then S:=S+#$0D#$0A;
end;
Memo.Text:=S;
finally SL.Free; end;
end;
 
 
 
initialization
{Create/load dictionary}
Dict:=TStringList.Create;
Dict.LoadFromFile('unixdict.txt');
Dict.Sorted:=True;
finalization
Dict.Free;
end.
 
</syntaxhighlight>
{{out}}
<pre>
Found: 16
belvedere dereference elsewhere erlenmeyer
evergreen everywhere exegete freewheel
nevertheless persevere preference referee
seventeen seventeenth telemeter tennessee
</pre>
 
 
=={{header|Draco}}==
<syntaxhighlight lang="draco">proc eword(*char line) bool:
word e;
char c;
bool ok;
ok := true;
e := 0;
while
c := line*;
line := line + 1;
ok and c ~= '\e'
do
if c='a' or c='i' or c='o' or c='u' then
ok := false
elif c='e' then
e := e + 1
fi
od;
ok and e>3
corp
 
proc nonrec main() void:
file(1024) dictfile;
[32] char buf;
*char line;
channel input text dict;
open(dict, dictfile, "unixdict.txt");
line := &buf[0];
while readln(dict; line) do
if eword(line) then writeln(line) fi
od;
close(dict)
corp</syntaxhighlight>
{{out}}
<pre>belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee</pre>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// 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
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}}
<pre>
Line 728 ⟶ 894:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: formatting io io.encodings.ascii io.files kernel math
sequences ;
 
Line 734 ⟶ 900:
[ [ "aiou" member? ] any? ] reject
[ [ CHAR: e = ] count 3 > ] filter
[ 1 + "%2d: " printf print ] each-index</langsyntaxhighlight>
{{out}}
<pre>
Line 757 ⟶ 923:
=={{header|Forth}}==
{{works with|Gforth}}
<langsyntaxhighlight lang="forth">: e3 ( addr u -- ? )
0 { ecount }
0 do
Line 793 ⟶ 959:
 
main
bye</langsyntaxhighlight>
 
{{out}}
Line 816 ⟶ 982:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">open "unixdict.txt" for input as #1
 
dim as string s, c
Line 830 ⟶ 996:
next i
if e>3 then print s
wend</langsyntaxhighlight>
{{out}}<pre>
belvedere
Line 848 ⟶ 1,014:
telemeter
tennessee
</pre>
 
=={{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]]
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]
}</syntaxhighlight>
{{out}}
<pre>
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include resources "unixdict.txt"
 
local fn ThreePlusEWord( string as CFStringRef ) as BOOL
long i, count = len(string), ecount = 0
for i = 0 to count -1
unichar ch = fn StringCharacterAtIndex( string, i )
select (ch)
case _"a", _"A", _"i", _"I", _"o", _"O", _"u", _"U" : exit fn = NO
case _"e", _"E" : ecount++
case else : continue
end select
next
if ecount > 3 then exit fn = YES
end fn = NO
 
void local fn CheckWords
CFURLRef url = fn BundleURLForResource( fn BundleMain, @"unixdict", @"txt", NULL )
CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
CFArrayRef words = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
CFMutableStringRef mutStr = fn MutableStringNew
NSUInteger count = 1
CFStringRef wordStr
for wordStr in words
if fn ThreePlusEWord( wordStr ) then MutableStringAppendString( mutStr, fn StringWithFormat( @"%2lu. %@\n", count, wordStr ) ) : count++
next
print mutStr
end fn
 
fn CheckWords
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
1. belvedere
2. dereference
3. elsewhere
4. erlenmeyer
5. evergreen
6. everywhere
7. exegete
8. freewheel
9. nevertheless
10. persevere
11. preference
12. referee
13. seventeen
14. seventeenth
15. telemeter
16. tennessee
</pre>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 895 ⟶ 1,145:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 918 ⟶ 1,168:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import System.IO
 
main = withFile "unixdict.txt" ReadMode $ \h -> do
Line 924 ⟶ 1,174:
putStrLn $ unlines $ filter valid words
valid w = not (any (`elem` "aiou") w) && length (filter (=='e') w) > 3</langsyntaxhighlight>
 
Or, defining the predicate in terms of a single fold:
 
<syntaxhighlight lang="haskell">import System.IO (readFile)
import Data.Bifunctor (first)
 
 
---------- MORE THAN THREE VOWELS, AND NONE BUT E --------
 
p :: String -> Bool
p = uncurry (&&) . first (3 <) . foldr rule (0, True)
rule :: Char -> (Int, Bool) -> (Int, Bool)
rule _ (n, False) = (n, False)
rule 'e' (n, b) = (succ n, b)
rule c (n, b)
| c `elem` "aiou" = (n, False)
| otherwise = (n, b)
 
--------------------------- TEST -------------------------
main :: IO ()
main = readFile "unixdict.txt"
>>= (putStrLn . unlines . filter p . lines)
</syntaxhighlight>
{{out}}
<pre>belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee</pre>
 
=={{header|J}}==
 
<syntaxhighlight lang="j"> >(#~ (0 4 0 0 0 -: 4 <. +/ .(=/)&'aeiou')@>) cutLF fread'unixdict.txt'
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
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.)
 
=={{header|JavaScript}}==
ECMAScript defines no file operations. Here, to read the dictionary, we use a library available to Apple's "JavaScript for Automation" embedding of a JS interpreter.
<syntaxhighlight lang="javascript">(() => {
"use strict";
 
// ----- MORE THAN THREE VOWELS, AND NONE BUT E ------
 
// p :: String -> Bool
const p = w => {
// True if the word contains more than three vowels,
// and none of its vowels are other than "e".
const
[noOtherVowels, eCount] = [...w].reduce(
([bool, n], c) => bool
? "e" === c
? [bool, 1 + n]
: "aiou".includes(c)
? [false, n]
: [bool, n]
: [false, n],
 
// Initial accumulator.
[true, 0]
);
 
return noOtherVowels && (3 < eCount);
};
 
// ---------------------- TEST -----------------------
const main = () =>
lines(
readFile(
"~/Desktop/unixdict.txt"
)
)
.filter(p)
.join("\n");
 
// --------------------- GENERIC ---------------------
 
// lines :: String -> [String]
const lines = s =>
// A list of strings derived from a single string
// which is delimited by \n or by \r\n or \r.
0 < s.length
? s.split(/\r\n|\n|\r/u)
: [];
 
// ----------------------- jxa -----------------------
 
// readFile :: FilePath -> IO String
const readFile = fp => {
// The contents of a text file at the
// given file path.
const
e = $(),
ns = $.NSString
.stringWithContentsOfFileEncodingError(
$(fp).stringByStandardizingPath,
$.NSUTF8StringEncoding,
e
);
 
return ObjC.unwrap(
ns.isNil() ? (
e.localizedDescription
) : ns
);
};
 
// MAIN ---
return main();
})();</syntaxhighlight>
{{Out}}
<pre>belvedere
dereference
Line 950 ⟶ 1,335:
 
===Using regular expressions===
<langsyntaxhighlight lang="jq">inputs
| select(test("[aiou]")|not)
| select(test("e.*e.*e.*e"))</langsyntaxhighlight>
===Regex-free solution===
<langsyntaxhighlight lang="jq">def count(s): reduce s as $x (null; .+1);
 
("aiou" | explode) as $disallow
Line 963 ⟶ 1,348:
count(.[] | select(. == 101)) > 3) # "e" is 101
| $word
</syntaxhighlight>
</lang>
{{out}}
Invocation example: jq -nrR program.jq unixdict.txt
Line 987 ⟶ 1,372:
=={{header|Julia}}==
See [[Alternade_words#Julia]] for the foreachword function.
<langsyntaxhighlight lang="julia">ecount(word) = count(x -> x == 'e', 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
 
foreachword("unixdict.txt", onlyevowelsmorethan3, colwidth=15, numcols=8)
</langsyntaxhighlight>{{out}}
<pre>
belvedere dereference elsewhere erlenmeyer evergreen everywhere exegete freewheel
nevertheless persevere preference referee seventeen seventeenth telemeter tennessee
</pre>
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">
import kotlin.io.path.Path
import kotlin.io.path.useLines
 
fun main() {
Path("unixdict.txt").useLines { lines ->
lines
.filter { line -> line.none { it in "aiou" } }
.filter { line -> line.count { it == 'e' } > 3 }
.forEach(::println)
}
}
</syntaxhighlight>
{{Output}}
<pre>
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
 
=={{header|Ksh}}==
<langsyntaxhighlight lang="ksh">
#!/bin/ksh
 
Line 1,035 ⟶ 1,453:
(( $(_countch "$REPLY" "e") >= MINE )) && print $REPLY
done < ${dictionary}
</syntaxhighlight>
</lang>
{{out}}<pre>
belvedere
Line 1,055 ⟶ 1,473:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">vowels = Characters["euioa"];
dict = Once[Import["https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt"]];
dict //= StringSplit[#, "\n"] &;
Line 1,061 ⟶ 1,479:
dict //= Select[Last /* Count["e"] /* GreaterThan[3]];
dict //= Select[Last /* Apply[SameQ]];
dict[[All, 1]]</langsyntaxhighlight>
{{out}}
<pre>{belvedere, dereference, elsewhere, erlenmeyer, evergreen, everywhere, exegete, freewheel, nevertheless, persevere, preference, referee, seventeen, seventeenth, telemeter, tennessee}</pre>
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils
 
const NonEVowels = ['a', 'i', 'o', 'u']
Line 1,077 ⟶ 1,495:
if vowel in word: break checkWord
inc count
stdout.write word.align(14), if count mod 4 == 0: '\n' else: ' '</langsyntaxhighlight>
 
{{out}}
Line 1,087 ⟶ 1,505:
=={{header|Pascal}}==
{{works with|Turbo Pascal}}
<langsyntaxhighlight lang="pascal">program EWords;
var
FileVar: Text;
Line 1,114 ⟶ 1,532:
end
end
end.</langsyntaxhighlight>
 
{{out}}
Line 1,136 ⟶ 1,554:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Find_words_which_contains_more_than_3_e_vowels
Line 1,142 ⟶ 1,560:
 
@ARGV = 'unixdict.txt';
tr/e// > 3 and tr/aiou// == 0 and print while <>;</langsyntaxhighlight>
{{out}}
belvedere
Line 1,162 ⟶ 1,580:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<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: #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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,174 ⟶ 1,592:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">moreThanThreeEs: procedure options(main);
declare dict file;
open file(dict) title('unixdict.txt');
Line 1,195 ⟶ 1,613:
close file(dict);
end moreThanThreeEs;</langsyntaxhighlight>
{{out}}
<pre>belvedere
Line 1,215 ⟶ 1,633:
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">with open('unixdict.txt', 'rt') as f:
for line in f.readlines():
if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3:
print(line.strip())</langsyntaxhighlight>
 
{{out}}
Line 1,238 ⟶ 1,656:
telemeter
tennessee</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ bit
[ 0 $ "aiou"
witheach
[ bit | ] ] constant
& 0 != ] is aiou ( c --> b )
 
[]
$ "rosetta/unixdict.txt" sharefile drop nest$
witheach
[ 0 over
witheach
[ dup char e = if
[ dip 1+ ]
aiou if
[ drop 0
conclude ] ]
3 > iff
[ nested join ]
else drop ]
 
50 wrap$</syntaxhighlight>
 
{{out}}
 
<pre>belvedere dereference elsewhere erlenmeyer
evergreen everywhere exegete freewheel
nevertheless persevere preference referee
seventeen seventeenth telemeter tennessee
</pre>
 
=={{header|R}}==
Adapting this from https://rosettacode.org/wiki/Find_words_which_contains_all_the_vowels#R is trivial.
<langsyntaxhighlight Rlang="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))
#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))))
eCount <- lengths(regmatches(dict, gregexec("e", dict)))
dict[apply(notEVowelCount, MARGIN = 1, function(x) all(x < 1)) & eCount > 3]</langsyntaxhighlight>
 
=={{header|Racket}}==
 
<langsyntaxhighlight lang="racket">#lang racket
 
;; probably not the best name, but matches the name of the task
Line 1,268 ⟶ 1,718:
 
(module+ main
qualifying-words)</langsyntaxhighlight>
 
{{out}}
Line 1,277 ⟶ 1,727:
 
Hardly even worth saving as a script file; an easily entered one-liner.
<syntaxhighlight lang="raku" perl6line>.say for "unixdict.txt".IO.lines.grep: { !/<[aiou]>/ and /e.*e.*e.*e/ };</langsyntaxhighlight>
{{out}}
<pre>
Line 1,300 ⟶ 1,750:
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.
 
<syntaxhighlight lang="raku" perl6line>unit sub MAIN ($vowel = 'e', $min = 4, $file = 'unixdict.txt');
.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} } )\
».subst(/<[":;,.?!_\[\]]>/, '', :g);</langsyntaxhighlight>
 
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,316 ⟶ 1,766:
 
=={{header|Red}}==
<langsyntaxhighlight lang="rebol">Red[]
 
words: read/lines %unixdict.txt
Line 1,329 ⟶ 1,779:
]
if all [retain e's > 3] [print word]
]</langsyntaxhighlight>
{{out}}
<pre>
Line 1,355 ⟶ 1,805:
 
It also allows the vowel to be specified, &nbsp; and also the minimum number of the specific vowels to be specified on the command line (CL) as well as the dictionary file identifier.
<langsyntaxhighlight 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*/
if char=='' | char=="," then char= 'e' /*Not specified? Then use the default.*/
Line 1,379 ⟶ 1,829:
end /*j*/
/*stick a fork in it, we're all done. */
say copies('─', 30) finds " words found having " many ' ' copies(char, many) " letters."</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 1,403 ⟶ 1,853:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
 
Line 1,444 ⟶ 1,894:
 
see "done..." + nl
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,466 ⟶ 1,916:
16. tennessee
done...
</pre>
 
=={{header|RPL}}==
As RPL is a language for calculators, it is not suitable for reading large text files.
« → w
« { 5 } 0 CON
1 w SIZE '''FOR''' j
w j DUP SUB
'''IF''' "AEIOUaeiou" SWAP POS '''THEN'''
LASTARG 1 - 5 MOD 1 +
DUP2 GET 1 + PUT
'''END'''
'''NEXT'''
DUP 2 GET 3 ≥ SWAP
[ 1 0 1 1 1 ] DOT NOT AND
» » ‘<span style="color:blue>EEE?</span>’ STO
 
"Seventeen" <span style="color:blue>EEE?</span> <span style="color:grey>@ returns 1 (true)</span>
"Eighteen" <span style="color:blue>EEE?</span> <span style="color:grey>@ returns 0 (false)</span>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">File.new("unixdict.txt").each do |word|
puts word if word.count("e") > 3 && word.count("aiou") == 0
end
</syntaxhighlight>
{{out}}
<pre>belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
 
=={{header|sed}}==
<syntaxhighlight lang="sed">#!/bin/sed -f
 
/^\([^aeiou]*e\)\{4\}[^aiou]*$/!d</syntaxhighlight>
{{out}}
<pre>
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
 
=={{header|Snobol}}==
<langsyntaxhighlight lang="snobol"> input(.words, 1,, 'unixdict.txt') :s(line)
output = 'Error!' :(end)
line word = words :f(end)
Line 1,475 ⟶ 1,991:
word 'e' arb 'e' arb 'e' arb 'e' :f(line)
output = word :(line)
end</langsyntaxhighlight>
 
{{out}}
Line 1,497 ⟶ 2,013:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Foundation
 
func e3(_ word: String) -> Bool {
Line 1,522 ⟶ 2,038:
} catch {
print(error.localizedDescription)
}</langsyntaxhighlight>
 
{{out}}
Line 1,546 ⟶ 2,062:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "io" for File
import "./fmt" for Fmt
 
var hasAIOU = Fn.new { |word| word.any { |c| "aiou".contains(c) } }
Line 1,558 ⟶ 2,074:
Fmt.print("$2d: $s", count, word)
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,578 ⟶ 2,094:
15: telemeter
16: tennessee
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">string 0; \Use zero-terminated strings
int I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
def LF=$0A, CR=$0D, EOF=$1A;
 
func Vowel(Ch); \Return 'true' if character is a vowel, except "e"
int Ch;
case Ch of ^a, ^i, ^o, ^u: return true
other return false;
 
func Es;
\Return 'true' if Word contains more than 3 e's and no other vowels
int Cnt, I;
[Cnt:= 0;
for I:= 0 to Len-1 do
[if Word(I) = ^e then Cnt:= Cnt+1;
if Vowel(Word(I)) then return false;
];
return Cnt > 3;
];
 
[FSet(FOpen("unixdict.txt", 0), ^I); \open dictionary and set it to device 3
OpenI(3);
repeat I:= 0;
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR
if Ch=LF or Ch=EOF then quit;
Word(I):= Ch;
I:= I+1;
];
Len:= I;
Word(I):= 0; \terminate string
if Es then [Text(0, Word); CrLf(0)];
until Ch = EOF;
]</syntaxhighlight>
 
{{out}}
<pre>
belvedere
dereference
elsewhere
erlenmeyer
evergreen
everywhere
exegete
freewheel
nevertheless
persevere
preference
referee
seventeen
seventeenth
telemeter
tennessee
</pre>
9,476

edits