Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: finding all combinations

by BrowserUk (Pope)
on Jan 14, 2008 at 01:50 UTC ( #662240=note: print w/replies, xml ) Need Help??


in reply to finding all combinations

Just because it uses List::Comprehensions which I recently discovered and absolutely love:

use List::Comprehensions;; comp1 { print join '-', @_ } [1,2,3], [7,8], [1,5,23,3];; 1-7-1 1-7-5 1-7-23 1-7-3 1-8-1 1-8-5 1-8-23 1-8-3 2-7-1 2-7-5 2-7-23 2-7-3 2-8-1 2-8-5 2-8-23 2-8-3 3-7-1 3-7-5 3-7-23 3-7-3 3-8-1 3-8-5 3-8-23 3-8-3

Or if you prefer:

comp1 { print join '-', reverse @_ } [1,5,23,3], [7,8], [1,2,3];; 1-7-1 2-7-1 3-7-1 1-8-1 2-8-1 3-8-1 1-7-5 2-7-5 3-7-5 1-8-5 2-8-5 3-8-5 1-7-23 2-7-23 3-7-23 1-8-23 2-8-23 3-8-23 1-7-3 2-7-3 3-7-3 1-8-3 2-8-3 3-8-3

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".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://662240]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2018-07-20 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (431 votes). Check out past polls.

    Notices?