Ordered words: Difference between revisions
→{{header|XPL0}}: simpler, better version
m (→{{header|Phix}}: rewrote to use unix_dict(), syntax coloured) |
(→{{header|XPL0}}: simpler, better version) |
||
Line 4,884:
=={{header|XPL0}}==
<lang XPL0>string 0; \use zero-terminated strings
char Word(25);▼
▲int DI, I, Ch, Ch0, MaxLen, Pass;
▲char Word;
def LF=$0A, CR=$0D, EOF=$1A;
▲[FSet(FOpen("unixdict.txt", 0), ^I); \load dictionary into Dict
DI:= 0; \ignore non-alpha characters: 0..9, ' and &▼
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR▼
if Ch=LF or Ch=EOF then quit;▼
MaxLen:= 0;
for Pass:= 1 to 2 do
[
repeat
[if
Word(I):=
if Ch < Ch0 then
Ch0:= Ch;
I:= I+1;
];
until Ch
];
]</lang>
|