We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getCombinations()
It could be nice to have fancy tuple return types for low length values, too.
length
export function getCombinations<T>(elements: T[], length: number): T[][] { if (elements.length < length) { return []; } const results: T[][] = []; const result: T[] = []; result.length = length; combine(length, 0); return results; function combine(len: number, start: number): void { if (len === 0) { results.push(result.slice()); return; } for (let i = start; i <= elements.length - len; i++) { result[result.length - len] = elements[i]; combine(len - 1, i + 1); } } }
The text was updated successfully, but these errors were encountered:
a1ec141
No branches or pull requests
It could be nice to have fancy tuple return types for low
length
values, too.The text was updated successfully, but these errors were encountered: