Name Math::Transform::List - Generate specified transformations of a list. Synopsis use Math::Transform::List; transform {say "@_"} [qw(a b c)], [1..3]; # a b c # b c a # c b a transform {say "@_"} [qw(a b c d)], [1..2], [3..4]; # a b c d # b a c d # a b d v # b a d c transform {say "@_"} [qw(a b c d)], [[1, 3], [2, 4]]; # a b c d # c d a b Description Generate and process all the all the transformations of a list using the standard Perl metaphor. "permute()" returns the number of transformations in both scalar and array context. Its easy to use and fast. Its written in 100% Pure Perl. Please note that the order in which the transformations are generated is not guaranteed, so please do not rely on it. The parameters to "permute()" are: 1: The code to be executed for each transformation. 2: The list to be transformed. This list is transformed as specified by the transformations. Each transformation of the list is handed to the code supplied in parameter 1 to be processed. 3: One or more transformations to be applied to the list. The transformations are applied repeatedly in all orders until no new transformations of the list are generated. Each new transformation of the list is handed to the code supplied in parameter 1 for processing. Transformations are represented as permutations in cyclic format based from 1 not 0. Two representations can be used to specify transformations. 3a: Single cycle. [1,2,3] The first element of the list will be replaced by the second, the second by the third, and the third by the first. 3a: Multi cycle. [[1,3], [2,4]] The first element of the list will be replaced by the third and vice versa, while simultaneously the second element is replaced by the fourth and vice versa. transform {say "@_"} [qw(a b c d)], [[1, 3], [2, 4]]; # a b c d # c d a b If you want to produce all possible transformations of a list you should consider Math::Permute::List as it is faster and easier to use than the equivalent: transform {} [1..$n], [1,2], [1..$n]; Export The "transform()" function is exported. Installation Standard Module::Build process for building and installing modules: perl Build.PL ./Build ./Build test ./Build install Or, if you're on a platform (like DOS or Windows) that doesn't require the "./" notation, you can do this: perl Build.PL Build Build test Build install Author PhilipRBrenan@handybackup.com http://www.handybackup.com See Also Math::Permute::List Math::Disarrange::List Math::Subsets::List Copyright Copyright (c) 2009 Philip R Brenan. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.