List::Permute::Limit - Permute all items list, with limit of number of items per result item
This document describes version 0.001 of List::Permute::Limit (from Perl distribution List-Permute-Limit), released on 2019-12-31.
use List::Permute::Limit qw(permute_iter permute); # iterator interface my $iter = permute_iter(items=>["zero","one","two","three"], nitems=>2); while (my $ary = $iter->()) { print "@{$ary}\n"; }
will print:
zero zero zero one zero two zero three one zero one one one two one three two zero two one two two two three three zero three one three two three three
To return the whole permutation in a list:
# array interface my @res = permute(items=>["zero","one","two","three"], nitems=>2); # => ( # ["zero", "zero"], # ["zero", "one"], # ["zero", "two"], # ["zero", "three"], # ["one", "zero"], # ["one", "one"], # ["one", "two"], # ["one", "three"], # ["two", "zero"], # ["two", "one"], # ["two", "two"], # ["two", "three"], # ["three", "zero"], # ["three", "one"], # ["three", "two"], # ["three", "three"], # )
This is just yet another list permutor module, with a limit on the number of items per result.
Usage:
permute(%args) -> any
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
items* => array
nitems => posint
Number of items of each permutation result.
Return value: (any)
permute_iter(%args) -> any
Please visit the project's homepage at https://metacpan.org/release/List-Permute-Limit.
Source repository is at https://github.com/perlancar/perl-List-Permute-Limit.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=List-Permute-Limit
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
List::Permutor, Math::Permute::List
Algorithm::Permute and variants.
Permute::Named, Permute::Named::Iter
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install List::Permute::Limit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Permute::Limit
CPAN shell
perl -MCPAN -e shell install List::Permute::Limit
For more information on module installation, please visit the detailed CPAN module installation guide.