Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > permutations of symbols?

Reply
Thread Tools

permutations of symbols?

 
 
Mike
Guest
Posts: n/a
 
      10-14-2009
Does anyone have some simple code to give all the permutations of
an array of symbols?

i.e. for two symbols in an array:

my @array = ('howard', 'geek');
my @permutations = &permute(@array);

print join(' ', $permutations[0]), "\n";
print join(' ', $permutations[1]), "\n";

howard geek
geek howard

It looks easy for two symbols. What about three, four, or more?

Mike

perl 5.8+
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      10-14-2009
Mike <(E-Mail Removed)> wrote:
>Does anyone have some simple code to give all the permutations of
>an array of symbols?


Anything wrong the answer to "perldoc -q permute"?

jue
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      10-14-2009
On 2009-10-14, Jürgen Exner <(E-Mail Removed)> wrote:
> Mike <(E-Mail Removed)> wrote:
>>Does anyone have some simple code to give all the permutations of
>>an array of symbols?

>
> Anything wrong the answer to "perldoc -q permute"?
>
> jue


I had found that, yes, thanks.
Sure enough, after posting the question I find an acceptable answer.
The tsc_permute looks more simple.
<http://docstore.mik.ua/orelly/perl/cookbook/ch04_20.htm>

Mike
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Slightly OT] Which algorithm for permutations Hendrik Maryns Java 0 03-03-2006 02:10 PM
Permutations of instances in array Karsten Wutzke Java 5 03-04-2004 04:49 AM
Finding permutations of a list in a map or multimap Daniel Fortin C++ 3 02-18-2004 09:51 AM
Permutations Ed Neukirch C++ 7 12-27-2003 12:44 AM
Permutations with repatitions in c++ Roger C++ 1 09-24-2003 10:52 PM



Advertisments