Combinatorics
, (*1)
Usage
You may add new elements to the list by using the add method:, (*2)
$instance = new Combinatorics(["foo", "bar"]);
$instance->add("baz");
$instance->add("qux");
// ["foo", "bar", "baz", "qux"]
You may also want to reset the list of elements by calling the reset method:, (*3)
$instance = new Combinatorics(["foo", "bar"]);
$instance->reset();
// []
Permutations
$elements = ["foo", "bar", "baz"];
$instance = new Combinatorics($elements);
foreach ($instance->permutations() as $value) {
...
}
// OR
foreach (Combinatorics::permutations($elements) as $value) {
...
}
// [
// ["foo", "bar", "baz"],
// ["bar", "foo", "baz"],
// ["bar", "baz", "foo"],
// ["foo", "baz", "bar"],
// ["baz", "foo", "bar"],
// ["baz", "bar", "foo"]
// ]
Structure
โโโ src
โย ย โโโ Combinatorics.php
โโโ tests
โย ย โโโ CombinatoricsTest.php
โโโ .editorconfig
โโโ .gitattributes
โโโ .gitignore
โโโ .travis.yml
โโโ LICENSE.md
โโโ README.md
โโโ composer.json
โโโ composer.lock
โโโ phpunit.xml
License
This package is open-sourced software licensed under the MIT license., (*4)