![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: character generatorby tmoertel (Chaplain) |
on Oct 25, 2004 at 20:00 UTC ( #402295=note: print w/replies, xml ) | Need Help?? |
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
|
|