Words containing "the" substring: Difference between revisions

add Refal
No edit summary
(add Refal)
 
(24 intermediate revisions by 17 users not shown)
Line 2:
 
;Task:
Using the dictionary   [https://web.archive.org/web/20180611003215/http://wwwwiki.puzzlers.org/pub/wordlists/unixdict.txt unixdict.txt],   search words containing "the" substring,
<br>then display the found words (on this page).
 
Line 12:
 
=={{header|11l}}==
<langsyntaxhighlight lang="11l">L(word) File(‘unixdict.txt’).read().split("\n")
I ‘the’ C word & word.len > 11
print(word)</langsyntaxhighlight>
 
{{out}}
Line 54:
=={{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 FindS(CHAR ARRAY text,sub)
BYTE i,j,found
 
Line 107:
 
FindWords(fname)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Words_containing_the_substring.png Screenshot from Atari 8-bit computer]
Line 118:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
Line 157:
Close (The_File);
end Main;
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 170:
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68"># find 12 character (or more) words that have "the" in them #
IF FILE input file;
STRING file name = "unixdict.txt";
Line 214:
print( ( newline, "found ", whole( the count, 0 ), " ""the"" words", newline ) );
close( input file )
FI</langsyntaxhighlight>
{{out}}
<pre>
Line 230:
 
Using just the core language — 'words':
<langsyntaxhighlight lang="applescript">on wordsContaining(textfile, searchText, minLength)
script o
property wordList : missing value
Line 245:
return o's output
end wordsContaining</langsyntaxhighlight>
 
Using just the core language — 'text items':
<langsyntaxhighlight lang="applescript">on wordsContaining(textFile, searchText, minLength)
script o
property textItems : missing value
Line 282:
return o's output
end wordsContaining</langsyntaxhighlight>
 
Using a shell script:
<langsyntaxhighlight lang="applescript">on wordsContaining(textFile, searchText, minLength)
-- Set up and execute a shell script which uses grep to find words containing the search text
-- (matching AppleScript's current case-sensitivity setting) and awk to pass those which
Line 299:
return paragraphs of (do shell script shellCode)
end wordsContaining</langsyntaxhighlight>
 
Using Foundation methods (AppleScriptObjC):
<langsyntaxhighlight lang="applescript">use AppleScript version "2.4" -- OS X 10.10 (Yosemite) or later
use framework "Foundation"
use scripting additions
Line 326:
return (theWords's filteredArrayUsingPredicate:(filter)) as list
end wordsContaining</langsyntaxhighlight>
 
Test code for the task with any of the above:
<langsyntaxhighlight lang="applescript">local textFile, output
set textFile to ((path to desktop as text) & "unixdict.txt") as «class furl»
-- considering case -- Uncomment this and the corresponding 'end' line for case-sensitive searches.
set output to wordsContaining(textFile, "the", 12)
-- end considering
return {count output, output}</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight lang="applescript">{32, {"authenticate", "chemotherapy", "chrysanthemum", "clothesbrush", "clotheshorse", "eratosthenes", "featherbedding", "featherbrain", "featherweight", "gaithersburg", "hydrothermal", "lighthearted", "mathematician", "neurasthenic", "nevertheless", "northeastern", "northernmost", "otherworldly", "parasympathetic", "physiotherapist", "physiotherapy", "psychotherapeutic", "psychotherapist", "psychotherapy", "radiotherapy", "southeastern", "southernmost", "theoretician", "weatherbeaten", "weatherproof", "weatherstrip", "weatherstripping"}}</langsyntaxhighlight>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">print.lines
{{output?}}
select read.lines relative "unixdict.txt" 'l ->
and? [11 < size l]
[contains? l "the"]</syntaxhighlight>
 
{{out}}
<lang rebol>select read.lines "unixdict.txt" 'l ->
 
and? contains? l "the"
<pre>authenticate
11 < size l</lang>
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping</pre>
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">FileRead, wList, % A_Desktop "\unixdict.txt"
SubString := "the"
list := ContainSubStr(wList, SubString)
Line 365 ⟶ 399:
}
return oRes
}</langsyntaxhighlight>
{{out}}
<pre>1- authenticate
Line 401 ⟶ 435:
 
=={{header|AutoIt}}==
<syntaxhighlight lang="autoit">
<lang AutoIt>
; Includes not needed if you don't want to use the constants
#include <FileConstants.au3>
Line 442 ⟶ 476:
 
ConsoleWrite("Found " & $iFoundResults & " words containing '" & $sStrToFind & "'")
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 482 ⟶ 516:
The following is an awk one-liner entered at a Posix shell.
 
<langsyntaxhighlight lang="awk">/Code$ awk '/the/ && length($1) > 11' unixdict.txt
authenticate
chemotherapy
Line 515 ⟶ 549:
weatherstrip
weatherstripping
/Code$ </langsyntaxhighlight>
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 OPEN "I",1,"unixdict.txt"
20 IF EOF(1) THEN CLOSE #1: END
30 LINE INPUT #1,W$
40 IF LEN(W$)>11 AND INSTR(W$,"the") THEN PRINT W$
50 GOTO 20</langsyntaxhighlight>
{{out}}
<pre>authenticate
Line 556 ⟶ 590:
weatherstrip
weatherstripping</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="vb">f = freefile
open f, "i:\unixdict.txt"
while not eof(f)
a$ = read (f)
if length(a$) > 11 and instr(a$, "the") then print a$
end while
close f</syntaxhighlight>
{{out}}
<pre>Same as BASIC entry.</pre>
 
==={{header|GW-BASIC}}===
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 OPEN "unixdict.txt" FOR INPUT AS #1
20 WHILE NOT EOF(1)
30 LINE INPUT #1, A$
40 IF LEN(A$) > 11 AND INSTR(A$,"the") THEN PRINT A$
50 WEND
60 CLOSE #1
70 END</syntaxhighlight>
{{out}}
<pre>Same as BASIC entry.</pre>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
<syntaxhighlight lang="qbasic">OPEN "unixdict.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, W$
IF LEN(W$) > 11 AND INSTR(W$, "the") THEN PRINT W$
WEND
CLOSE #1
END</syntaxhighlight>
{{out}}
<pre>Same as BASIC entry.</pre>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let read(word) = valof
Line 595 ⟶ 665:
endread()
$)
$)</langsyntaxhighlight>
{{out}}
<pre style='height:50ex;'>authenticate
Line 631 ⟶ 701:
 
=={{header|C}}==
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <string.h>
 
Line 650 ⟶ 720:
fclose(f);
return 0;
}</langsyntaxhighlight>
{{out}}
<pre style="height:50ex;">authenticate
Line 686 ⟶ 756:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <fstream>
 
Line 702 ⟶ 772:
}
return 0;
}</langsyntaxhighlight>
{{out}}
<pre style="height:50ex;">authenticate
Line 738 ⟶ 808:
 
=={{header|Common Lisp}}==
<syntaxhighlight lang="lisp">
<lang Lisp>
(defun print-words-containing-substring (str len path)
(with-open-file (s path :direction :input)
Line 747 ⟶ 817:
 
(print-words-containing-substring "the" 11 "unixdict.txt")
</syntaxhighlight>
</lang>
{{out}}
<pre>authenticate
Line 787 ⟶ 857:
{{libheader| System.IOUtils}}
{{Trans|Go}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program Words_containing_the_substring;
 
Line 816 ⟶ 886:
 
readln;
end.</langsyntaxhighlight>
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">\util.g
 
proc theword(*char line) bool:
Line 840 ⟶ 910:
close(dict)
corp</langsyntaxhighlight>
{{out}}
<pre style='height:50ex;'>authenticate
Line 877 ⟶ 947:
=={{header|Factor}}==
{{works with|Factor|0.99 2020-08-14}}
<langsyntaxhighlight lang="factor">USING: io io.encodings.ascii io.files kernel math sequences ;
 
"unixdict.txt" ascii file-lines
[ length 11 > ] filter
[ "the" swap subseq? ] filter
[ print ] each</langsyntaxhighlight>
{{out}}
<pre style="height:18em">
Line 921 ⟶ 991:
=={{header|Forth}}==
Developed with Gforth 0.7.9
<langsyntaxhighlight Forthlang="forth">11 constant WordLen
128 constant max-line
 
Line 954 ⟶ 1,024:
 
Test
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 994 ⟶ 1,064:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran">
program main
implicit none
Line 1,009 ⟶ 1,079:
enddo
end program main
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,049 ⟶ 1,119:
=={{header|FreeBASIC}}==
Reuses some code from [[Odd words#FreeBASIC]]
<langsyntaxhighlight lang="freebasic">#define NULL 0
 
type node
Line 1,096 ⟶ 1,166:
next i
curr = curr->nxt
wend</langsyntaxhighlight>
{{out}}
<pre>
Line 1,131 ⟶ 1,201:
weatherstrip
weatherstripping</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
 
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES}
 
void local fn DoIt
CFURLRef url
CFStringRef string, wd
ErrorRef err = NULL
CFArrayRef array
CFMutableArrayRef mutArray
url = fn URLWithString( @"https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt" )
string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, @err )
if ( string )
array = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
mutArray = fn MutableArrayWithCapacity(0)
for wd in array
if ( len(wd) > 11 and fn StringContainsString( wd, @"the" ) )
MutableArrayAddObject( mutArray, wd )
end if
next
string = fn ArrayComponentsJoinedByString( mutArray, @"\n" )
NSLog(@"%@",string)
else
NSLog(@"%@",err)
end if
end fn
 
fn DoIt
 
HandleEvents</syntaxhighlight>
 
{{out}}
<pre>
authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping
</pre>
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import (
Line 1,166 ⟶ 1,307:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,206 ⟶ 1,347:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import System.IO (readFile)
import Data.List (isInfixOf)
 
Line 1,213 ⟶ 1,354:
let res = [ w | w <- lines txt, isInfixOf "the" w, length w > 11 ]
putStrLn $ show (length res) ++ " words were found:"
mapM_ putStrLn res</langsyntaxhighlight>
<pre>λ> main
32 words were found:
Line 1,248 ⟶ 1,389:
weatherstrip
weatherstripping</pre>
 
=={{header|J}}==
<syntaxhighlight lang="j"> >(#~ (+./@E.~&'the'*11<#)@>) cutLF fread'unixdict.txt'
authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping</syntaxhighlight>
 
=={{header|JavaScript}}==
<syntaxhighlight lang="javascript">
<lang javaScript>
document.write(`
<p>Select a file: <input type="file" id="file"></p>
Line 1,279 ⟶ 1,455:
fr.readAsText(f);
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,287 ⟶ 1,463:
 
=={{header|jq}}==
<langsyntaxhighlight lang="sh">jq -nrR 'inputs|select(length>11 and index("the"))' unixdict.txt</langsyntaxhighlight>
One could also use `test("the")` here instead, the difference being that the argument of `test` is a JSON string interpreted as a regular expression.
{{out}}
Line 1,293 ⟶ 1,469:
=={{header|Julia}}==
See [[Alternade_words]] for the foreachword function.
<langsyntaxhighlight lang="julia">containsthe(w, d) = occursin("the", w) ? w : ""
foreachword("unixdict.txt", containsthe, minlen = 12)
</langsyntaxhighlight>{{out}}
<pre>
Word source: unixdict.txt
Line 1,308 ⟶ 1,484:
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">for word in io.open("unixdict.txt", "r"):lines() do
if #word > 11 and word:find("the") then
print(word)
end
end</langsyntaxhighlight>
{{out}}
<pre>authenticate
Line 1,348 ⟶ 1,524:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">dict = Once[Import["https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt"]];
dict //= StringSplit[#, "\n"] &;
dict //= Select[StringLength /* GreaterThan[11]];
Select[dict, StringContainsQ["the"]]</langsyntaxhighlight>
{{out}}
<pre>{authenticate, chemotherapy, chrysanthemum, clothesbrush, clotheshorse, eratosthenes, featherbedding, featherbrain, featherweight, gaithersburg, hydrothermal, lighthearted, mathematician, neurasthenic, nevertheless, northeastern, northernmost, otherworldly, parasympathetic, physiotherapist, physiotherapy, psychotherapeutic, psychotherapist, psychotherapy, radiotherapy, southeastern, southernmost, theoretician, weatherbeaten, weatherproof, weatherstrip, weatherstripping}</pre>
Line 1,357 ⟶ 1,533:
=={{header|min}}==
{{works with|min|0.27.1}}
<langsyntaxhighlight lang="min">"unixdict.txt" fread "\n" split
(length 11 >) filter
("the" indexof -1 !=) filter
(puts!) foreach</langsyntaxhighlight>
{{out}}
<pre style="height:18em">
Line 1,398 ⟶ 1,574:
 
=={{header|Nanoquery}}==
<langsyntaxhighlight Nanoquerylang="nanoquery">words = split(new(Nanoquery.IO.File).open("unixdict.txt").readAll(),"\n")
for word in words
if (word .contains. "the") and (len(word) > 11)
println word
end if
end for</langsyntaxhighlight>
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">import strutils
 
var count = 0
Line 1,412 ⟶ 1,588:
if word.len > 11 and word.contains("the"):
inc count
echo ($count).align(2), ' ', word</langsyntaxhighlight>
 
{{out}}
Line 1,449 ⟶ 1,625:
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">
class Thes {
function : Main(args : String[]) ~ Nil {
Line 1,475 ⟶ 1,651:
};
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,487 ⟶ 1,663:
southernmost theoretician weatherbeaten weatherproof weatherstrip
weatherstripping</pre>
 
=={{header|Pascal}}==
{{works with|Extended Pascal}}
<syntaxhighlight lang="pascal">
program wordsContainingTheSubstring(input, output);
var
word: string(22);
begin
while not EOF do
begin
readLn(word);
if (length(word) > 11) and_then (index(word, 'the') > 0) then
begin
writeLn(word)
end
end
end.
</syntaxhighlight>
If <tt>unixdict.txt</tt> is fed to <tt>stdin</tt>, the standard input file, you will get the following output:
{{out}}
authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping
 
=={{header|Perl}}==
Perl one-liner entered from a Posix shell:
 
<langsyntaxhighlight lang="perl">/Code$ perl -n -e '/(\w*the\w*)/ && length($1)>11 && print' unixdict.txt
authenticate
chemotherapy
Line 1,524 ⟶ 1,753:
weatherstrip
weatherstripping
/Code$ </langsyntaxhighlight>
 
=={{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;">the</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;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">word</span><span style="color: #0000FF;">)></span><span style="color: #000000;">11</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">match</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"the"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">word</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">words</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;">the</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;">"found %d 'the' words:\n%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">words</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;">words</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: #008000;">", "</span><span style="color: #0000FF;">)})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,538 ⟶ 1,767:
authenticate, chemotherapy, chrysanthemum, ..., weatherproof, weatherstrip, weatherstripping
</pre>
=={{header|PHP}}==
<syntaxhighlight lang="php"><?php foreach(file("unixdict.txt") as $w) echo (strstr($w, "the") && strlen(trim($w)) > 11) ? $w : "";</syntaxhighlight>
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Put "c:\unixdict.txt" into a path.
Line 1,554 ⟶ 1,785:
Repeat.
Wait for the escape key.
Shut down.</langsyntaxhighlight>
{{out}}
<pre style="height:18em">
Line 1,592 ⟶ 1,823:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">the: procedure options(main);
declare dict file;
open file(dict) title('unixdict.txt');
Line 1,605 ⟶ 1,836:
close file(dict);
end the;</langsyntaxhighlight>
{{out}}
<pre>authenticate
Line 1,641 ⟶ 1,872:
 
=={{header|Processing}}==
<langsyntaxhighlight Processinglang="processing">String[] words = loadStrings("unixdict.txt");
for (String word : words) {
if (word.contains("the") && word.length() > 11) {
println(word);
}
}</langsyntaxhighlight>
{{out}}
<pre style="height:18em">authenticate
Line 1,682 ⟶ 1,913:
 
=={{header|Python}}==
<syntaxhighlight lang="python">import urllib.request as request
Entered from a Posix shell:
 
with request.urlopen("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt") as f:
<lang python>/Code$ python -c 'import sys
a = f.read().decode("ASCII").split()
> for line in sys.stdin:
 
> if "the" in line and len(line.strip()) > 11:
for s in a:
> print(line.rstrip())
if len(s) > 11 and "the" in s:
> ' < unixdict.txt
print(s)</syntaxhighlight>
authenticate
 
<pre>authenticate
chemotherapy
chrysanthemum
Line 1,720 ⟶ 1,953:
weatherproof
weatherstrip
weatherstripping</pre>
/Code$ </lang>
 
=={{header|Quackery}}==
Line 1,728 ⟶ 1,960:
Presented as a dialogue in the Quackery shell (REPL).
 
<langsyntaxhighlight Quackerylang="quackery">/O> [ $ 'sundry/fsm.qky' loadfile ] now!
... [ dup
... [ $ 'the' buildfsm ] constant
Line 1,751 ⟶ 1,983:
weatherstripping
 
Stack empty.</langsyntaxhighlight>
 
 
=={{header|R}}==
 
<syntaxhighlight lang="rsplus">words <- readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
grep("the", words[nchar(words) > 11], value = T)</syntaxhighlight>
 
{{out}}
 
<pre> [1] "authenticate" "chemotherapy" "chrysanthemum" "clothesbrush"
[5] "clotheshorse" "eratosthenes" "featherbedding" "featherbrain"
[9] "featherweight" "gaithersburg" "hydrothermal" "lighthearted"
[13] "mathematician" "neurasthenic" "nevertheless" "northeastern"
[17] "northernmost" "otherworldly" "parasympathetic" "physiotherapist"
[21] "physiotherapy" "psychotherapeutic" "psychotherapist" "psychotherapy"
[25] "radiotherapy" "southeastern" "southernmost" "theoretician"
[29] "weatherbeaten" "weatherproof" "weatherstrip" "weatherstripping"</pre>
 
=={{header|Raku}}==
A trivial modification of the [[ABC_words#Raku|ABC words]] task.
 
<syntaxhighlight lang="raku" perl6line>put 'unixdict.txt'.IO.words».fc.grep({ (.chars > 11) && (.contains: 'the') })\
.&{"{+$_} words:\n " ~ .batch(8)».fmt('%-17s').join: "\n "};</langsyntaxhighlight>
{{out}}
<pre>32 words:
Line 1,767 ⟶ 2,015:
 
=={{header|Red}}==
<langsyntaxhighlight lang="rebol">Red[]
 
foreach word read/lines %unixdict.txt [
if all [11 < length? word find word "the"] [print word]
]</langsyntaxhighlight>
{{out}}
<pre>
Line 1,807 ⟶ 2,055:
weatherstripping
</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
, <ReadFile 1 'unixdict.txt'>: e.Dict
= <Each Show <Filter TheWord e.Dict>>;
};
 
TheWord {
(e.Word), e.Word: e.X 'the' e.Y,
<Lenw e.Word>: s.Len e.Word,
<Compare s.Len 11>: '+' = T;
(e.Word) = F;
};
 
ReadFile {
s.Chan e.Filename =
<Open 'r' s.Chan e.Filename>
<ReadFile (s.Chan)>;
 
(s.Chan), <Get s.Chan>: {
0 = <Close s.Chan>;
e.Line = (e.Line) <ReadFile (s.Chan)>;
};
};
 
Each {
s.F = ;
s.F t.I e.X = <Mu s.F t.I> <Each s.F e.X>;
};
 
Filter {
s.F = ;
s.F t.I e.X, <Mu s.F t.I>: {
T = t.I <Filter s.F e.X>;
F = <Filter s.F e.X>;
};
};
 
Show {
(e.X) = <Prout e.X>;
};</syntaxhighlight>
{{out}}
<pre>authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping</pre>
 
=={{header|REXX}}==
Line 1,817 ⟶ 2,139:
Programming note: &nbsp; If the minimum length is negative, &nbsp; it indicates to find the words &nbsp; (but not display them), &nbsp; and
<br>only the display the count of found words.
<langsyntaxhighlight lang="rexx">/*REXX program finds words that contain the substring "the" (within an identified dict.)*/
parse arg $ minL iFID . /*obtain optional arguments from the CL*/
if $=='' | $=="," then $= 'the' /*Not specified? Then use the default.*/
Line 1,840 ⟶ 2,162:
/*stick a fork in it, we're all done. */
say copies('─', 25) finds " words (with a min. length of" ,
minL') that contains the substring: ' $</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 1,886 ⟶ 2,208:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
cStr = read("unixdict.txt")
wordList = str2list(cStr)
Line 1,912 ⟶ 2,234:
 
see "done..." + nl
</syntaxhighlight>
</lang>
Output:
<pre>
Line 1,950 ⟶ 2,272:
32. weatherstripping
done...
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">File.foreach("unixdict.txt"){|w| puts w if w.size > 11 && w.match?("the") }
</syntaxhighlight>
{{out}}
<pre>authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping
</pre>
 
Line 1,955 ⟶ 2,315:
 
{{works with|Smalltalk/X}}
<langsyntaxhighlight lang="smalltalk">'unixdict.txt' asFilename contents
select:[:word | (word size > 11) and:[word includesString:'the']]
thenDo:#transcribeCR</langsyntaxhighlight>
 
if counting per word is required (which is overkill here, as there are no duplicates in the file), keep them in a bag:
<langsyntaxhighlight lang="smalltalk">bagOfWords := Bag new.
'unixdict.txt' asFilename contents
select:[:word | (word size > 11) and:[word includesString:'the']]
Line 1,966 ⟶ 2,326:
 
bagOfWords transcribeCR.
bagOfWords size transcribeCR</langsyntaxhighlight>
 
Note: #transcribeCR is a method in Object which says: "Transcript showCR:self".
Line 1,972 ⟶ 2,332:
{{works with|Smalltalk/X}}
Variant (as script file). Save to file: "filter.st":
<langsyntaxhighlight lang="smalltalk">#! /usr/bin/env stx --script
[Stdin atEnd] whileFalse:[
|word|
Line 1,980 ⟶ 2,340:
Stdout nextPutLine: word
]
]</langsyntaxhighlight>
Execute with:
<langsyntaxhighlight lang="shell">chmod +x filter.st
./filter.st < unixdict.txt</langsyntaxhighlight>
 
The output from the above counting snippet:
Line 1,999 ⟶ 2,359:
 
32</pre>
 
=={{header|sed}}==
<syntaxhighlight lang="sed">#!/bin/sed -f
 
/^.\{12\}/!d
/the/!d</syntaxhighlight>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program the_words;
dict := open("unixdict.txt", "r");
loop doing geta(dict, word); until eof(dict) do
word ?:= "";
if #word > 11 and "the" in word then
print(word);
end if;
end loop;
close(dict);
end program;</syntaxhighlight>
{{out}}
<pre>authenticate
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
eratosthenes
featherbedding
featherbrain
featherweight
gaithersburg
hydrothermal
lighthearted
mathematician
neurasthenic
nevertheless
northeastern
northernmost
otherworldly
parasympathetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
southeastern
southernmost
theoretician
weatherbeaten
weatherproof
weatherstrip
weatherstripping</pre>
 
=={{header|Standard ML}}==
<langsyntaxhighlight lang="sml">val hasThe = String.isSubstring "the"
 
fun isThe12 s = size s > 11 andalso hasThe s
Line 2,009 ⟶ 2,420:
o List.filter isThe12
o String.tokens Char.isSpace
o TextIO.inputAll) TextIO.stdIn ^ "\n")</langsyntaxhighlight>
{{out}}
<pre>authenticate chemotherapy chrysanthemum clothesbrush clotheshorse eratosthenes featherbedding featherbrain featherweight gaithersburg hydrothermal lighthearted mathematician neurasthenic nevertheless northeastern northernmost otherworldly parasympathetic physiotherapist physiotherapy psychotherapeutic psychotherapist psychotherapy radiotherapy southeastern southernmost theoretician weatherbeaten weatherproof weatherstrip weatherstripping</pre>
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Foundation
 
let minLength = 12
Line 2,027 ⟶ 2,438:
} catch {
print(error.localizedDescription)
}</langsyntaxhighlight>
 
{{out}}
Line 2,066 ⟶ 2,477:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">foreach w [read [open unixdict.txt]] {
if {[string first the $w] != -1 && [string length $w] > 11} {
puts $w
}
}</langsyntaxhighlight>
{{out}}
<pre>authenticate
Line 2,106 ⟶ 2,517:
 
=={{header|VBA}}==
<langsyntaxhighlight lang="vb">Sub Main_Contain()
Dim ListeWords() As String, Book As String, i As Long, out() As String, count As Integer
Book = Read_File("C:\Users\" & Environ("Username") & "\Desktop\unixdict.txt")
Line 2,127 ⟶ 2,538:
Read_File = Input(LOF(Nb), #Nb)
Close #Nb
End Function</langsyntaxhighlight>
{{out}}
<pre>Found : 32 words : authenticate, chemotherapy, chrysanthemum, clothesbrush, clotheshorse, eratosthenes, featherbedding, featherbrain,
Line 2,133 ⟶ 2,544:
otherworldly, parasympathetic, physiotherapist, physiotherapy, psychotherapeutic, psychotherapist, psychotherapy, radiotherapy,
southeastern, southernmost, theoretician, weatherbeaten, weatherproof, weatherstrip, weatherstripping
</pre>
 
=={{header|VBScript}}==
Run it with Cscript
<syntaxhighlight lang="vb">
with createobject("ADODB.Stream")
.charset ="UTF-8"
.open
.loadfromfile("unixdict.txt")
s=.readtext
end with
a=split (s,vblf)
with new regexp
.pattern=".*?the.*"
 
for each i in a
if len(trim(i))>=11 then
if .test(i) then wscript.echo i
end if
next
end with
</syntaxhighlight>
{{out}}
<pre>
authenticate
brotherhood
calisthenic
chemotherapy
chrysanthemum
clothesbrush
clotheshorse
clothesline
earthenware
endothelial
endothermic
eratosthenes
featherbedding
featherbrain
featherweight
furtherance
furthermore
furthermost
gaithersburg
grandfather
grandmother
hydrothermal
kinesthesis
leatherback
leatherneck
leatherwork
lighthearted
mathematician
netherlands
netherworld
neurasthenic
nevertheless
nonetheless
northeastern
northernmost
otherworldly
parasympathetic
parentheses
parenthesis
parenthetic
physiotherapist
physiotherapy
psychotherapeutic
psychotherapist
psychotherapy
radiotherapy
smithereens
southeastern
southernmost
sympathetic
thenceforth
theoretician
therapeutic
thereabouts
theretofore
weatherbeaten
weatherproof
weatherstrip
weatherstripping
</pre>
=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">import os
 
fn main() {
mut count := 1
mut text :=''
unixdict := os.read_file('./unixdict.txt') or {panic('file not found')}
for word in unixdict.split_into_lines() {
if word.contains('the') && word.len > 11 {text += count++.str() + ': $word \n'}
}
println(text)
}</syntaxhighlight>
 
{{out}}
<pre>
1: authenticate
2: chemotherapy
3: chrysanthemum
4: clothesbrush
5: clotheshorse
6: eratosthenes
7: featherbedding
8: featherbrain
9: featherweight
10: gaithersburg
11: hydrothermal
12: lighthearted
13: mathematician
14: neurasthenic
15: nevertheless
16: northeastern
17: northernmost
18: otherworldly
19: parasympathetic
20: physiotherapist
21: physiotherapy
22: psychotherapeutic
23: psychotherapist
24: psychotherapy
25: radiotherapy
26: southeastern
27: southernmost
28: theoretician
29: weatherbeaten
30: weatherproof
31: weatherstrip
32: weatherstripping
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<langsyntaxhighlight ecmascriptlang="wren">import "io" for File
import "./fmt" for Fmt
 
var wordList = "unixdict.txt" // local copy
Line 2,149 ⟶ 2,691:
Fmt.print("$2d: $s", count, word)
}
}</langsyntaxhighlight>
 
{{out}}
Line 2,189 ⟶ 2,731:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">string 0; \use zero-terminated strings
int I, Ch, Len;
char Word(100); \(longest word in unixdict.txt is 22 chars)
Line 2,208 ⟶ 2,750:
[Text(0, Word); CrLf(0)];
until Ch = EOF;
]</langsyntaxhighlight>
 
{{out}}
Line 2,247 ⟶ 2,789:
 
=={{header|Yabasic}}==
<langsyntaxhighlight Yabasiclang="yabasic">// Rosetta Code problem: http://rosettacode.org/wiki/Words_containing_"the"_substring
// by Galileo, 02/2022
 
Line 2,255 ⟶ 2,797:
if len(a$) > 11 and instr(a$, "the") print a$
wend
close a</langsyntaxhighlight>
{{out}}
<pre>authenticate
Line 2,293 ⟶ 2,835:
{{omit from|6502 Assembly|unixdict.txt is much larger than the CPU's address space.}}
{{omit from|8080 Assembly|See 6502 Assembly.}}
{{omit from|Computer/zero Assembly|See 6502 Assembly.}}
{{omit from|Z80 Assembly|See 6502 Assembly.}}
2,094

edits