in reply to recursively generating permutations

Did you run across How do I permute N elements of a list?

What is difficult about nesting map? The only trick is to assign $_ to some other variable within the (outer) body block before calling the inner map.


Caution: Contents may have been coded under pressure.
  • Comment on Re: recursively generating permutations

Replies are listed 'Best First'.
Re^2: recursively generating permutations
by spurperl (Priest) on Aug 19, 2005 at 11:36 UTC
    Nesting maps isn't difficult, but the idiom for using the $_ of the outer map in the inner map is ugly. A lambda-like idiom with a named $_ would be nicer.

    Disclaimer: as can be seen from my previous posts, this is not a criticism of Perl (which is my favorite programming language), but rather ruminations on how to make the code more natural. After writing a lot of code, we all start getting a "feel" for "elegant" code. This is what I'm trying to explore with various programming problems.