1. Re: enumerating all the combinations
> From: ck lester
>
> Can anybody decode this into EUPHORIA?
<snip>
Erm...no thanks...But I've done something similar (you can also check the
archives--Jiri posted an algoritm in response to Kat towards the end of
July) in EuSQL.
Basically, I've got several of sequences of data [from different tables]
stored in one sequence, and I want to 'enumerate all the combinations'. I
use sequence rx to keep track of the current index on each sequence. There
is a sequence called max, which is a sequence of integers that are the total
of records in each sequence of data. I also have min, which keeps track of
minimum indices I want, since depending on the type of join I use, it could
be zero (null). Integer 'qx' keeps track of which table I'm currently
moving through (I always start at the last table). The loop below will go
through all combinations.
You can see the rest of the code at
-- figure out what the next combination should be...
rx[qx] += 1
while rx[qx] > max[qx] do
-- We've gone over the max, so we need to increase
-- the previous index...
if qx = 1 then
-- We've looked at all combinations!
exit
end if
-- reset this table
rx[qx] = min[qx]
-- go back towards the beginning
qx -= 1
-- and increment the next one...
rx[qx] += 1
-- we're moving on, so we need to reset the null_join flag
null_join = 0
end while