in reply to Combinations / permutations... not even sure what this is called

Re: Combinations / permutations... not even sure what this is called

It's called cross-product.

You can use the glob-hack like Marshall did, as long as you have no problem with stringification.

Otherwise I have code mimicking Perl6's X-operator, if your interested I can post it on Monday.

Cheers Rolf

PS: > This isn't a homework question.

I doubt this, only complete beginners don't know nested loops.

  • Comment on Re: Combinations / permutations... not even sure what this is called (Cross-Product)

Replies are listed 'Best First'.
Re^2: Combinations / permutations... not even sure what this is called (Cross-Product)
by Marshall (Canon) on Oct 29, 2011 at 13:19 UTC
    I think calling my solution a "hack" is a bit too strong. It is a legal albeit not so obvious use of glob.

    One thing is for sure, if this is a homework, the prof is going to freak out if the student presents my code as the homework answer! He/she just won't believe that it was unassisted.

    I leave it to the OP to write some nested loops that will do the same job.