Words containing "the" substring: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) m (added omits) |
(Added solution for Action!) |
||
Line 50: | Line 50: | ||
weatherstrip |
weatherstrip |
||
weatherstripping |
weatherstripping |
||
</pre> |
|||
=={{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. |
|||
<lang Action!>BYTE FUNC FindS(CHAR ARRAY text,sub) |
|||
BYTE i,j,found |
|||
i=1 |
|||
WHILE i<=text(0)-sub(0)+1 |
|||
DO |
|||
found=0 |
|||
FOR j=1 TO sub(0) |
|||
DO |
|||
IF text(i+j-1)#sub(j) THEN |
|||
found=0 EXIT |
|||
ELSE |
|||
found=1 |
|||
FI |
|||
OD |
|||
IF found THEN |
|||
RETURN (i) |
|||
FI |
|||
i==+1 |
|||
OD |
|||
RETURN (0) |
|||
BYTE FUNC IsValidWord(CHAR ARRAY word) |
|||
IF word(0)<=11 THEN RETURN (0) FI |
|||
IF FindS(word,"the")=0 THEN RETURN(0) FI |
|||
RETURN (1) |
|||
PROC FindWords(CHAR ARRAY fname) |
|||
CHAR ARRAY line(256) |
|||
CHAR ARRAY tmp(256) |
|||
BYTE pos,dev=[1] |
|||
pos=2 |
|||
Close(dev) |
|||
Open(dev,fname,4) |
|||
WHILE Eof(dev)=0 |
|||
DO |
|||
InputSD(dev,line) |
|||
IF IsValidWord(line) THEN |
|||
IF pos+line(0)>=39 THEN |
|||
PutE() pos=2 |
|||
FI |
|||
Print(line) Put(32) |
|||
pos==+line(0)+1 |
|||
FI |
|||
OD |
|||
Close(dev) |
|||
RETURN |
|||
PROC Main() |
|||
CHAR ARRAY fname="H6:UNIXDICT.TXT" |
|||
FindWords(fname) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Words_containing_the_substring.png Screenshot from Atari 8-bit computer] |
|||
<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> |
</pre> |
||