1.0.0 • Published 1 year ago

array-permutation-recursive v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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
1.0.0

1 year ago