24fe35e78e47f992626e27456b066ef3f8b4bedf
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.
Description
My contributions to simple-statistics/simple-statistics: 2 commits
32 KiB
0 Stars
1 Watchers
0 Forks
Languages
JavaScript
100%