nolin / 排列组合
生成排列和组合。
dev-master
2024-04-02 08:51 UTC
Requires (Dev)
- pestphp/pest: ^2.34
This package is auto-updated.
Last update: 2024-10-02 09:51:56 UTC
README
此PHP包提供了生成组合和排列的功能。最初受到eoincampbell/combinatorics的启发,本包是对PHP环境的适配。在翻译过程中,可能丢失了一些注释;然而,您可以参考原始文件以获取这些详细信息。
安装
通过Composer安装此包
composer require nolin/permutations:dev-master
用法
安装后,您可以在PHP代码中使用它,如下所示
// Include the library use Nolin\Permutations\Permutations; // Create a permutations object with an array of elements $permutations = new Permutations([1, 2, 3, 4, 5]); // Iterate through the permutations foreach ($permutations as $permutation) { // Perform desired actions with each permutation // e.g., echo/print, store in an array, etc. }
变化特性
变化已转换为VariationsWithRepetition和VariationsWithoutRepetition。原本来自源材料的C# VariationsWithoutRepetition特性并不完全符合预期的结果。因此,对current()方法进行了升级。
包仓库
您可以自由地探索代码库,报告问题或提交pull请求。您的贡献受到欢迎和赞赏。