|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re: character generatorby tmoertel (Chaplain) |
| on Oct 25, 2004 at 16:00 UTC ( [id://402295]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
Here's one way to compute the combinations that can be created
by drawing a single element from each of a list of given sets:
The combinations function takes a list of sets (each represented as an arrayref) and returns the combinations that can be created from them: With this function, we can turn to your question of how best to represent your character sets. I would just use strings to keep things simple. A helper function will convert strings into the form needed by combinations and then convert the results back into strings: Let's use our new helper to find all of the 3-character combinations that can be made from the charset "abc": We can even draw successive characters from different character sets: I hope this gives you some helpful ideas. Cheers, Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||