Skip to content

Feature request: combinations #1665

@itzTheMeow

Description

@itzTheMeow

Would be similar to this implementation: https://github.com/SeregPie/lodash.combinations

lodash.combinations

_.combinations(collection, k)

Calculates all possible combinations without repetition of a certain size.

argument description
collection A collection of distinct values to calculate the groups from.
k A number as the size of each group.

Returns the calculated groups as an array of arrays.

Calculate all possible combinations of all possible sizes.

let combinations = _.flatMap([2, 4, 6], (v, i, a) => _.combinations(a, i + 1));
// => [[2], [4], [6], [2, 4], [2, 6], [4, 6], [2, 4, 6]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions