# Combinatorial Methods

These methods create sequences of the very large combinations of values.

## cartesianProduct

Generates sequence of the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) of an arbitrary number of columns of data.

{% tabs %}
{% tab title="Usage" %}

```typescript
const sequence: Seq<[string, number]> = cartesianProduct(
  ["a", "b", "c"],
  [1, 2, 3],
)
```

{% endtab %}

{% tab title="Type Definition" %}

```typescript
type cartesianProduct = <T>(...inputs: T[][]) => Seq<T[]>
```

{% endtab %}
{% endtabs %}

## powerSet

Generates sequence of Sets of a [Power set](https://en.wikipedia.org/wiki/Power_set).

{% tabs %}
{% tab title="Usage" %}

```typescript
const sequence: Seq<Set<string>> = powerSet(["a", "b", "c"])
```

{% endtab %}

{% tab title="Type Definition" %}

```typescript
type powerSet = <T>(...items: T[]) => Seq<Set<T>>
```

{% endtab %}
{% endtabs %}

## combination

Generates sequence of Sets of a [Combination](https://en.wikipedia.org/wiki/Combination) of a given length.

{% tabs %}
{% tab title="Usage" %}

```typescript
const sequence: Seq<Set<string>> = combination(["a", "b", "c"], 2)
```

{% endtab %}

{% tab title="Type Definition" %}

```typescript
type combination = <T>(items: T[], size: number = items.length) => Seq<Set<T>>
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://leisure.tdreyno.com/api/combinatorics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
