array-permutation-recursive

1.0.0 • Public • Published

array-permutation-recursive

Get array permutations in lexicographical order with a recursive function.

Install

npm install array-permutation-recursive

Use

# es6
import { getPermutations } from 'array-permutation-recursive';
const { getPermutations } = require('array-permutation-recursive');

Example

const { getPermutations } = require('array-permutation-recursive');

const example = [ "Insulin", "Test", "Diagnosis" ]
  
const permutations = getPermutations(example)

console.log(permutations)

 /** Expected output:

  Array(6) [ (3) […], (3) […], (3) […], (3) […], (3) […], (3) […] ]
  0: Array(3) [ "Insulin", "Test", "Diagnosis" ]
  ​1: Array(3) [ "Insulin", "Diagnosis", "Test" ]
  ​2: Array(3) [ "Test", "Insulin", "Diagnosis" ]
  ​3: Array(3) [ "Test", "Diagnosis", "Insulin" ]
  ​4: Array(3) [ "Diagnosis", "Insulin", "Test" ]
  ​5: Array(3) [ "Diagnosis", "Test", "Insulin" ]
  
*/

Similar packages

  • Permu, Get all possible permutations of a given length, and a given array of attributes. link

Readme

Keywords

none

Package Sidebar

Install

npm i array-permutation-recursive

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.51 kB

Total Files

6

Last publish

Collaborators

  • felixdrp