Ordered words: Difference between revisions
Content deleted Content added
Added correct 4tH string |
→{{header|Tcl}}: ++ smalltalk |
||
Line 1,628:
(loop (read-char port) (cons char word) result)))))))
</lang>
=={{header|Smalltalk}}==
{{works with|GNU Smalltalk}}
<lang smalltalk>|file dict r t|
file := FileStream open: 'unixdict.txt' mode: FileStream read.
dict := Set new.
"load the whole dict into the set before, 'filter' later"
[ file atEnd ] whileFalse: [
dict add: (file upTo: Character nl) ].
"find those with the sorted letters, and sort them by length"
r := ((dict
select: [ :w | (w asOrderedCollection sort) = (w asOrderedCollection) ] )
asSortedCollection: [:a :b| (a size) > (b size) ] ).
"get those that have length = to the max length, and sort alphabetically"
r := (r select: [:w| (w size) = ((r at: 1) size)]) asSortedCollection.
r do: [:e| e displayNl].</lang>
Output:
<pre>abbott
accent
accept
access
accost
almost
bellow
billow
biopsy
chilly
choosy
choppy
effort
floppy
glossy
knotty</pre>
=={{header|Tcl}}==
Line 1,659 ⟶ 1,699:
abbott accent accept access accost almost bellow billow biopsy chilly choosy choppy effort floppy glossy knotty
</pre>
=={{header|TUSCRIPT}}==
<lang tuscript>
|