Prelude API
    Preparing search index...

    Function unsafeCombinations

    • Returns a generator that yields all combinations of the input iterable. WARNING: This loads the entire input iterable into memory, which can be unsafe for large collections. For a safer version with constrained memory usage, use combinations.ts.

      Type Parameters

      • T

        The type of elements in the iterable

      Parameters

      • Optionalk: number

        Optional size of each combination (defaults to the length of the input)

      Returns (g: Iterable<T>) => Generator<T[]>

      All possible combinations as arrays

      G.pipe(
      [1, 2, 3],
      G.unsafeCombinations(2),
      G.array
      ) // [[1, 2], [1, 3], [2, 3]]

      G.pipe(
      [1, 2, 3, 4],
      G.unsafeCombinations(3),
      G.array
      ) // [[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]