Ordered words: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: rewrote to use unix_dict(), syntax coloured) |
(→{{header|XPL0}}: simpler, better version) |
||
Line 4,884: | Line 4,884: | ||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
<lang XPL0>string 0; \use zero-terminated strings |
<lang XPL0>string 0; \use zero-terminated strings |
||
⚫ | |||
int Dict(26000); \pointers to words (enough for unixdict.txt) |
|||
⚫ | |||
int DictSize; \actual number of pointers in Dict |
|||
⚫ | |||
⚫ | |||
def LF=$0A, CR=$0D, EOF=$1A; |
def LF=$0A, CR=$0D, EOF=$1A; |
||
⚫ | |||
⚫ | |||
OpenI(3); \assume alphabetical order and all lowercase |
|||
⚫ | |||
repeat Dict(DI):= Reserve(0); \get pointer to memory used to store Word |
|||
Word:= Dict(DI); |
|||
I:= 0; |
|||
⚫ | |||
⚫ | |||
Word(I):= Ch; |
|||
I:= I+1; |
|||
]; |
|||
Word(I):= 0; \terminate Word string |
|||
I:= Reserve(I+1); \reserve memory used for Word |
|||
DI:= DI+1; \next dictionary entry |
|||
until Ch = EOF; |
|||
DictSize:= DI; |
|||
MaxLen:= 0; |
MaxLen:= 0; |
||
for Pass:= 1 to 2 do |
for Pass:= 1 to 2 do |
||
[ |
[OpenI(3); |
||
repeat |
repeat I:= 0; Ch0:= 0; |
||
loop [repeat Ch:= ChIn(3) until Ch # CR; \remove possible CR |
|||
if Ch=LF or Ch=EOF then |
|||
if |
[if I > MaxLen then MaxLen:= I; |
||
if I=MaxLen & Pass=2 then |
|||
[Word(I):= 0; Text(0, Word); CrLf(0)]; |
|||
quit; |
|||
]; |
|||
Word(I):= Ch; |
|||
if Ch < Ch0 then |
if Ch < Ch0 then |
||
⚫ | |||
⚫ | |||
⚫ | |||
Ch0:= Ch; |
Ch0:= Ch; |
||
I:= I+1; |
I:= I+1; |
||
]; |
]; |
||
until Ch = EOF; |
|||
until DI >= DictSize; |
|||
]; |
]; |
||
]</lang> |
]</lang> |