in reply to Next permutation

The Perl built in glob function can do permutations. Here are some examples:
In a permutation, order matters, in a combination, order doesn't matter.
#!/usr/bin/perl use strict; use warnings; my @permutations = glob "{1,2,3}" x 3; print "@permutations\n"; @permutations = glob "{1,1,7}" x 3; print "@permutations\n"; @permutations = glob "{a,b,c}{1,2}"; print "@permutations\n"; __END__ extra new lines added for readability Example1: 111 112 113 121 122 123 131 132 133 211 212 213 221 222 223 231 232 233 311 312 313 321 322 323 331 332 333 Example2: 111 111 117 111 111 117 171 171 177 111 111 117 111 111 117 171 171 177 711 711 717 711 711 717 771 771 777 Example:3 combinations "one from column A", one from column "B". a1 a2 b1 b2 c1 c2

Replies are listed 'Best First'.
Re^2: Next permutation
by Cristoforo (Curate) on Feb 25, 2019 at 20:58 UTC
    That is called a cross product :-)

    It doesn't give the permutation ( 3 * 2 * 1 = 3! ) (The permutation of 3 objects gives 6 tuples. The cross product gives 3 * 3 * 3 = 27 tuples).

      Ok. well anyway the OP divulged some more info about the his requirements at Re^2: Next permutation and I wrote some code in response to that. The OP wants some enhancements and I've asked the OP to give it a stab on his own. Let's see how that goes......
        I've asked the OP to give it a stab on his own. Let's see how that goes......

        To my knowledge, he's never posted any code; neither as a part of one of his (usually obscure and unexplained) requirements, nor as an answer to anyone else.

        I've avoided giving him the time of day for a long time now; as he would only then modify the requirements to the ToD on the south pole of Jupiter. In Tagalog.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
        In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit