Socket
Book a DemoInstallSign in
Socket

partition-refinement-iterator

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

partition-refinement-iterator

Progressively refine partitions of a finite set

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

partition-refinement-iterator

Progressively refine partitions of a finite set.

Think of it like a more generic binary search that will keep dividing a finite set until all numbers in it have been emitted.

Example

var iterator = require('partition-refinement-iterator');

var iterate = iterator(Number(process.argv[2]));

while (true) {
  var n = iterate();
  if (typeof n == 'undefined') break;
  console.log(n);
}

Output:

 ∴  partition-refinement-iterator : node example.js 1
0
 ∴  partition-refinement-iterator : node example.js 2
0
1
 ∴  partition-refinement-iterator : node example.js 3
0
1
2
 ∴  partition-refinement-iterator : node example.js 4
0
2
1
3
 ∴  partition-refinement-iterator : node example.js 5
0
2
1
3
4
 ∴  partition-refinement-iterator : node example.js 6
0
3
1
4
2
5
 ∴  partition-refinement-iterator : node example.js 7
0
3
1
5
2
4
6
 ∴  partition-refinement-iterator : node example.js 8
0
4
2
6
1
3
5
7

Installation

$ npm install partition-refinement-iterator

API

iterator(length)

Return a function that can be called length times to get the next index in the refinement process.

License

MIT

FAQs

Package last updated on 12 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts