| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
* tests/015/comb.tl: New tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* combi.c (permi_get, permi_peek): Fix algorithm.
(permi_mark): New static function.
(permi_ops): Reference permi_mark for mark operation.
(permi): Initialize it->ul.next to nao as required by
new get/peek algorithm.
(rpermi_get, rpermi_peek): Fix algorithm.
(rpermi_mark): New static function.
(rpermi_ops): Reference permi_mark for mark operation.
(rpermi): Initialize it->ul.next to nao as required
by new get/peek algorithm.
(combi_get, combi_peek, combi_mark, combi_clone): New static
functions.
(combi_ops): New static structure.
(combi): New function.
(rcombi_get, rcombi_peek, rcombi_mark, rcombi_clone): New
static functions.
(rcombi_ops): New static structure.
(rcombi): New function.
* combi.h (combi, rcombi): Declared.
* tests/015/comb.tl: New tests.
|
|
|
|
|
|
|
|
|
| |
* combi.c (rperm, comb, rcomb): In the default
case for generic sequences, check k, like
in the other cases and return the special
case result.
* tests/015/comb.tl: New tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
perm doesn't generate items of the right type. We need
to add the original sequence to the state vector and
use make_like.
The new generic sequence support in rperm is broken, too.
* combi.c (perm_while_fun, perm_gen_fun_common): Rename p
variable to vec.
(perm_init_common): Rename to perm_init. Take one more
argument and store in new fourth element of state vector.
(perm_vec, perm_list, perm_str): Pass nil to new parameter
of perm_init.
(perm_seq_gen_fun): Use perm_list_gen_fun to get list
permutations, and coerce each one to the same type as
the sequence with make_like.
(rcomb_seq_gen_fun): Remove redundant call to
rcomb_gen_fun_common. The rcomb_list_gen_fun function
is called, which does this already, so we lose every
other sequence element.
* tests/015/comb.tl: New tests.
|
|
|
|
| |
* tests/015/comb.tl: New tests.
|
|
The comb function is broken; some combinations of items
are missing in the output. This is because the iteration
reset step in comb_gen_fun_common handles only one
column of the state, neglecting to reset the other
columns: what is now done by the for (j = i ...
loop. I'm changing the representation of the state from
a list of lists to a vector of lists. Moreover, it is not
reversed. This allows the loop in comb_gen_fun_common
to perform random access.
* combi.c (k_conses): Return a vector, that is not
reversed.
(comb_init): New helper function to slightly abstract
the use of k_conses.
(comb_while_fun): Termination now occurs if the state
vector is nil (degenerate case, like k items chosen
from n, when k > n), or if the vector has nil in
element zero (special flag situation).
(comb_gen_fun_common): Rewritten, with correction.
The logic is similar. Since we have random access,
we don't need the "prev" variable. When we reset
a column iterator, we now also populate all the
columns to the right of it. For instance, if a
given column resets to (a b c), the one to the right
must reset to (b c), and so on. In the broken function,
this is what was not done, resulting in missing
items due to, say, a column resetting to (a b c)
but the one next to it remaining at (c).
(comb_list_gen_fun): Drop nreverse.
(comb_vec_gen_fun, comb_str_gen_fun, comb_hash_gen_fun):
Use the same i iterator for the state and the output object,
accessing the vector directly.
(comb_list, comb_vec, comb_str, comb_hash): Use comb_init.
* tests/015/comb.tl: New file.
|