Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Conditional Elimination

by pileofrogs (Priest)
on Aug 30, 2011 at 23:35 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-16 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found