Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Latest commit

 

History

History
72 lines (47 loc) · 1.31 KB

combinatorics.md

File metadata and controls

72 lines (47 loc) · 1.31 KB

Combinatorial Methods

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

cartesianProduct

Generates sequence of the Cartesian product of an arbitrary number of columns of data.

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

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

{% endtab %}

{% tab title="Type Definition" %}

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

{% endtab %} {% endtabs %}

powerSet

Generates sequence of Sets of a Power set.

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

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

{% endtab %}

{% tab title="Type Definition" %}

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

{% endtab %} {% endtabs %}

combination

Generates sequence of Sets of a Combination of a given length.

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

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

{% endtab %}

{% tab title="Type Definition" %}

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

{% endtab %} {% endtabs %}