@aureooms/js-set-partitiondeprecated

Set partition algorithms for JavaScript

Usage no npm install needed!

<script type="module">
  import aureoomsJsSetPartition from 'https://cdn.skypack.dev/@aureooms/js-set-partition';
</script>

README

:bento: @aureooms/js-set-partition

The Zahlen symbol
User:Watchduck / CC BY 3.0

Set partition algorithms for JavaScript. See docs.

:building_construction: Caveat emptor! This is work in progress. Code may be working. Documentation may be present. Coherence may be. Maybe.

:warning: The code requires regeneratorRuntime to be defined, for instance by importing regenerator-runtime/runtime.

import {
    enumerate,
    count,
    _count,
    sequence,
    _sequence,
    isPartition
} from '@aureooms/js-set-partition';

import {range, map} from '@aureooms/js-itertools';

enumerate(range(0)); // []
enumerate(range(1)); // [[0]]
enumerate(range(2)); // [[0], [1]] [[0, 1]]

count(0); // 1n
count(1); // 1n
count(2); // 2n
count(3); // 5n
count(4); // 15n
count(5); // 52n
count(6); // 203n
count(26); // 49631246523618756274n

_count(1,6); // 203
_count(1,26); // ???

sequence(); // 1n 1n 2n 3n 5n 15n 52n 203n ...
_sequence(1); // 1 1 2 3 5 15 52 203 ...

isPartition(range(5), [range(5)]); // true
isPartition(range(5), map(x => [x], range(5))); // true
isPartition(range(5), map(x => (function* () {yield x;})(), range(5))); // true
isPartition(range(5), [[0], [1], [2], [3], [4]]); // true
isPartition(range(5), [[0, 1], [2], [3], [4]]); // true
isPartition(range(5), [[2, 1], [3], [0, 4]]); // true

isPartition(range(5), [[], [0], [1], [2], [3], [4]]); // false
isPartition(range(5), [[0], [0], [1], [2], [3], [4]]); // false
isPartition(range(5), [[5], [0], [1], [2], [3], [4]]); // false

License Version Build Dependencies Dev dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code technical debt Documentation Package size