Merge pull request #6775 from dearblue/array-combination.2

This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-04-23 18:56:46 +09:00
committed by GitHub
+3 -7
View File
@@ -1619,13 +1619,9 @@ ary_combination_next(mrb_state *mrb, mrb_value self)
}
else {
/* Reset dependent indices */
for (mrb_int i = pos + 1; i < state->n; i++) {
if (state->permutation) {
state->indices[i] = 0;
}
else {
state->indices[i] = state->indices[i - 1];
}
mrb_int reset = state->permutation ? 0 : state->indices[pos];
for (pos++; pos < state->n; pos++) {
state->indices[pos] = reset;
}
}