|There's more than one way to do things|
Working with Binary Numbersby shoness (Friar)
|on Sep 24, 2007 at 20:36 UTC||Need Help??|
shoness has asked for the wisdom of the Perl Monks concerning the following question:
The novice monk asked his teachers this kōan...
I've a set of binary (base 2) numbers, where the '-' means BOTH 0 and 1 are to be substituted:
Hence the above array reads:
Now the last part of my problem is easy, since I can change binary to decimal like this:
The middle part, expanding the array members that contain '-' should probably be done using a recursive subroutine call since there can be multiple dashes. This is where I'm working now:
My approach to the binary conversion is brute-force. My approach to solve the "-" expansion is going to have to get more brute-force. I'm sure that I'm missing something on both accounts....
I looked into it, but I don't think Set::Scalar is useful here. I also don't see any proper binary number modules to start with up on CPAN either.
Your help is appreciated.