Skip to content

Commit 0f91c38

Browse files
authored
Another fix for cyclicity
When an ordering is found to be the best, it wins over all previously tried candidates, not just the most recent one. This oversight becomes apparent when looking at the recent discussion on the Cadabra Q&A forum.
1 parent 04b735d commit 0f91c38

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

core/algorithms/sort_product.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ Algorithm::result_t sort_product::apply(iterator& st)
142142
compare.clear();
143143
auto es=compare.equal_subtree(one, two);
144144
if(es==Ex_comparator::match_t::no_match_greater || es==Ex_comparator::match_t::match_index_greater) {
145-
--candidate;
146-
candidate=candidates.erase(candidate);
145+
candidate=candidates.erase(candidates.begin(), candidate);
147146
one=candidate->at(digit-1);
148147
++candidate;
149148
}

0 commit comments

Comments
 (0)