Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Conditional Elimination

by pileofrogs (Priest)
on Aug 30, 2011 at 23:35 UTC ( #923318=note: print w/replies, xml ) Need Help??

in reply to Conditional Elimination

Like everyone has said, it depends heavily on your particular situation. I'm going to mention an approach that you almost certainly should NOT use. If clarity is important, DO NOT DO THIS. But it's fun, so I'm going to try to write about it.

You can pack the variables into fewer variables.

Lets say you have two variables A and B. Each can have a value from 0 - 99. Then we could multiply Ax100 and add it to B. Then we have 1 variable instead of two but it contains all the information of the 2 original variables and you can check it easily in one operation.

To continue the example, Lets say if A=34 and B=75 the world explodes. All we have to do is our little operation and then see if it equals 3475.

This is the same thing you see with bit maps for things like file permission modes.

Again, this is NOT AT ALL recommended for clarity. It's just another way of thinking of a problem like this.

It's also probably not faster than a whole buncha == && == &&. I think it would depend on how many variables, how many iterations it goes through etc...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://923318]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2021-01-27 23:41 GMT
Find Nodes?
    Voting Booth?