dualfroz 24fe35e78e fix(combinations-replacement): return an empty list for a non-positive group size
combinationsReplacement recurses on x.slice(i, x.length), which at i = 0 is
as long as the input, so the only exit left is the k === 1 base case. For
k <= 0 the counter starts below that case and moves away from it, and the
recursion overflows the stack. The sibling combinations recurses on
x.slice(i + 1, x.length), runs out of input and returns [] for the same
arguments.

Guard the non-positive group size up front so both functions agree.
2026-09-03 14:04:54 +02:00
S
Description
My contributions to simple-statistics/simple-statistics: 2 commits
32 KiB
0 Stars 1 Watchers 0 Forks
Languages
JavaScript 100%