Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

RE: permutations?

by merlyn (Sage)
on Jun 14, 2000 at 05:58 UTC ( #18028=note: print w/ replies, xml ) Need Help??


in reply to permutations?

Untested, but I often get this stuff right on the first try... :)

my $words = { 'lng' => ['lang', 'long', 'leng', 'loo'], 'sentance' => ['sentence'], 'thxs' => ['this', 'thus'] }; print map "$_\n", phol($words); sub phol { my($key, $value, @rest) = %{+shift}; if (@rest) { return map { my $r = $_; map { "$_ $r" } @$value } phol({@rest}); } else { return @$value; } }

-- Randal L. Schwartz, Perl hacker


Comment on RE: permutations?
Download Code
Replies are listed 'Best First'.
Re: RE: permutations?
by Anonymous Monk on Jul 08, 2002 at 15:25 UTC
    Is there any easier way to get values listed as permutations? I mean I can't use those Perl things at all. And I would like to get all 120 permutations of five letters listed. Is there any way find such program without programming? jamkoi@surfeu.fi

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://18028]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2015-07-30 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls