https://github.com/seregpie/lodash.multipermutations
Calculates all possible permutations with repetition of a certain size.
https://github.com/seregpie/lodash.multipermutations
array collection combinatorics lodash mixin multipermutation
Last synced: 5 months ago
JSON representation
Calculates all possible permutations with repetition of a certain size.
- Host: GitHub
- URL: https://github.com/seregpie/lodash.multipermutations
- Owner: SeregPie
- License: mit
- Created: 2020-06-04T09:53:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-04T11:56:48.000Z (almost 5 years ago)
- Last Synced: 2024-06-19T20:24:29.556Z (11 months ago)
- Topics: array, collection, combinatorics, lodash, mixin, multipermutation
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lodash.multipermutations
`_.multipermutations(collection, n)`
Calculates all possible permutations with repetition of a certain size.
| argument | description |
| ---: | :--- |
| `collection` | A collection of distinct values to calculate the permutations from. |
| `n` | The number of values to combine. |Returns a new array.
## setup
### npm
```shell
npm i lodash.multipermutations
```### ES module
```javascript
import 'lodash.multipermutations';
import _ from 'lodash';
```### Node
```javascript
require('lodash.multipermutations');
let _ = require('lodash');
```### browser
```html
```
## usage
```javascript
let multipermutations = _.multipermutations([0, 1], 3);
// => [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
```---
Also accepts array-like values.
```javascript
let multipermutations = _('abc').multipermutations(2).map(v => _.join(v, '')).value();
// => ['aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc']
```## see also
- [lodash.combinations](https://github.com/SeregPie/lodash.combinations)
- [lodash.permutations](https://github.com/SeregPie/lodash.permutations)
- [lodash.multicombinations](https://github.com/SeregPie/lodash.multicombinations)
- [lodash.product](https://github.com/SeregPie/lodash.product)