Words containing "the" substring: Difference between revisions

Content added Content deleted
(Added XPL0 example.)
(→‎{{header|Smalltalk}}: lowercase in unixdict anyway)
Line 667: Line 667:


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
Not clear to me if case matters or not. The code does either (replace trueOrFalseWhoKnows by true or false)


{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>'unixdict.txt' asFilename contents
<lang smalltalk>'unixdict.txt' asFilename contents
select:[:word | (word size > 11) and:[word includesString:'the' caseSensitive:trueOrFalseWhoKnows]]
select:[:word | (word size > 11) and:[word includesString:'the']]
thenDo:#transcribeCR</lang>
thenDo:#transcribeCR</lang>


Line 677: Line 676:
<lang smalltalk>bagOfWords := Bag new.
<lang smalltalk>bagOfWords := Bag new.
'unixdict.txt' asFilename contents
'unixdict.txt' asFilename contents
select:[:word | (word size > 11) and:[word includesString:'the' caseSensitive:trueOrFalseWhoKnows]]
select:[:word | (word size > 11) and:[word includesString:'the']]
thenDo:[:word | bagOfWords add:word. word transcribeCR].
thenDo:[:word | bagOfWords add:word. word transcribeCR].


Line 691: Line 690:
|word|
|word|
((word := Stdin nextLine) size > 11
((word := Stdin nextLine) size > 11
and:[word includesString:'the' caseSensitive:trueOrFalseWhoKnows]
and:[word includesString:'the']
) ifTrue:[
) ifTrue:[
Stdout nextPutLine: word
Stdout nextPutLine: word