Skip to content

Commit e82c30b

Browse files
📚 docs(README): Add API draft.
1 parent b9123bc commit e82c30b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,37 @@ See [docs](https://aureooms.github.io/js-set-partition/index.html).
2121
> :warning: The code requires `regeneratorRuntime` to be defined, for instance by importing
2222
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
2323
24+
```js
25+
import {range, map} from '@aureooms/js-itertools';
26+
import {partitions, npartitions, bell, isPartition} from '@aureooms/js-set-partition';
27+
28+
partitions(range(0)); // []
29+
partitions(range(1)); // [[0]]
30+
partitions(range(2)); // [[0], [1]] [[0, 1]]
31+
32+
npartitions(0); // 1
33+
npartitions(1); // 1
34+
npartitions(2); // 2
35+
npartitions(3); // 5
36+
npartitions(4); // 15
37+
npartitions(5); // 52
38+
npartitions(6); // 203
39+
npartitions(26); // 49631246523618756274n
40+
41+
bell(); // 1 2 3 5 15 52 203 ...
42+
43+
isPartition(range(5), [range(5)]); // true
44+
isPartition(range(5), map(x => [x], range(5))); // true
45+
isPartition(range(5), map(x => (function* () {yield x;})(), range(5))); // true
46+
isPartition(range(5), [[0], [1], [2], [3], [4]]); // true
47+
isPartition(range(5), [[0, 1], [2], [3], [4]]); // true
48+
isPartition(range(5), [[2, 1], [3], [0, 4]]); // true
49+
50+
isPartition(range(5), [[], [0], [1], [2], [3], [4]]); // false
51+
isPartition(range(5), [[0], [0], [1], [2], [3], [4]]); // false
52+
isPartition(range(5), [[5], [0], [1], [2], [3], [4]]); // false
53+
```
54+
2455
[![License](https://img.shields.io/github/license/aureooms/js-set-partition.svg)](https://raw.githubusercontent.com/aureooms/js-set-partition/main/LICENSE)
2556
[![Version](https://img.shields.io/npm/v/@aureooms/js-set-partition.svg)](https://www.npmjs.org/package/@aureooms/js-set-partition)
2657
[![Build](https://img.shields.io/travis/aureooms/js-set-partition/main.svg)](https://travis-ci.org/aureooms/js-set-partition/branches)

0 commit comments

Comments
 (0)