webchalkboard has asked for the wisdom of the Perl Monks concerning the following question:
Hi again,
I have a much simplier and cooler question this time, and was wondering the best way to do this.
Basically I have an array of words for example ('the','cat','sat','on','the','matt') and I want to create lots of different combinations of these words, so I would like to end up with short two word phrases like 'cat matt' and 'cat sat' or 'matt cat the'.
What is the best way of achieving this result? I was thinking about counting the number of items in the array and then connecting random elements together. Most phrases would only be about 4 words long, and if I could get every permutation of these words up to say 50 permutations that would be perfect... i'm sure there is a cool perl way, any suggestions?
Many thanks,
Tom
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Manipulating Arrays
by Taulmarill (Deacon) on Aug 11, 2005 at 11:57 UTC | |
by holli (Abbot) on Aug 11, 2005 at 12:04 UTC | |
|
Re: Manipulating Arrays
by davidrw (Prior) on Aug 11, 2005 at 12:28 UTC | |
|
Re: Manipulating Arrays
by Limbic~Region (Chancellor) on Aug 11, 2005 at 12:37 UTC | |
by Anonymous Monk on Aug 11, 2005 at 15:45 UTC | |
|
Re: Manipulating Arrays
by chester (Hermit) on Aug 11, 2005 at 13:18 UTC | |
|
Re: Manipulating Arrays
by salva (Canon) on Aug 11, 2005 at 12:50 UTC | |
|
Re: Manipulating Arrays
by webchalkboard (Scribe) on Aug 11, 2005 at 13:11 UTC |