Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
[atcroft]: abner: Do you mean something like SELECT `foo`, `bar` FROM `table_name' WHERE (( `foo` = "asdf" ) OR ( `bar` = 'asdw' )); Or something else?
[abner]: yes. i am familiar with mysql but ignorant about how to get around the fact that placeholders can only represent single scalar values.
[abner]: my $sth = $dbh->prepare(' SELECT * FROM charge WHERE cpt = ?') or die "Couldn't prepare statement: " . $dbh->errstr;

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-01-24 03:46 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (201 votes). Check out past polls.