Boolean logic is boooooring...

toph99

Diamond Member
Aug 25, 2000
5,505
0
0
and i have to go through this same class in my next one too (there's a 2 month overlap, more or less, between my two computer courses) :|
anyone here?
 

Noriaki

Lifer
Jun 3, 2000
13,640
1
71
Boring, Yes. Hard, No.

It could be boring and hard. At least it's easy and boring. Look on the brightside :p
 

toph99

Diamond Member
Aug 25, 2000
5,505
0
0
good point, but it's still boring :p
especially considering i have to do the same thing in both classes.... i guess it's a plus that i get to sleep during on of the periosds ;)
 

Pennstate

Diamond Member
Oct 14, 1999
3,211
0
0
yeah? Evaluate this:




if( (line.substr(0,4) == "ATOM" && line.substr(17,3) == "GLU" &&
(line.substr (13,3) == "OE1" || line.substr (13,3) == "OE2" ))
||
(line.substr(0,4) == "ATOM" && line.substr(17,3) == "ASP" &&
(line.substr (13,3) == "OD1" || line.substr (13,3) == "OD2" ))
||
(line.substr(0,4) == "ATOM" && line.substr(17,3) == "ARG" &&
(line.substr (13,3) == "NH1" || line.substr (13,3) == "NH2" ))
||
(line.substr(0,4) == "ATOM" && line.substr(17,3) == "LYS" &&
line.substr (13,3) == "NZ ")
||
( (line.substr(0,4) == "ATOM" && line.substr(17,3) == "HIS" &&
(line.substr (13,3) == "ND1" || line.substr (13,3) == "NE2" ))
&&
( (res_in[0] != atof (line.substr(30,8).c_str())&&
res_in[1] != atof (line.substr(38,8).c_str())&&
res_in[2] != atof (line.substr(46,8).c_str()))
&&
(res_in[3] != atof (line.substr(30,8).c_str())&&
res_in[4] != atof (line.substr(38,8).c_str())&&
res_in[5] != atof (line.substr(46,8).c_str())) )
))
 

toph99

Diamond Member
Aug 25, 2000
5,505
0
0
haven't gotten that far yet :p
my teacher was just explaining the principle behind it... i had already heard it from him 3 diff. times before in 3 diff. classes
 

~zonker~

Golden Member
Jan 23, 2000
1,493
0
0
Pennstate... I might use a case statement for that much combinatorial logic, not too much easier to code, but alot easier to read ;)
 

Noriaki

Lifer
Jun 3, 2000
13,640
1
71
Pennstate, since you just tossed that up to stir the pot, I'm going to knitpick:

Boolean algebra is a group of closed function/operations on a set of two elements usually - but it's not required - representing true or false (1/0, T/F, on/off, pick two any two will work)

Since that messy if statement has all kinds of functions and whatnot, certianly more that two elements it's not actually boolean logic. In order for it to qualify as boolean logic you would have to reduce all of your func() == string to a truth value of 1 or 0 (true or false if I you like), after which time you would have a long string of 1s and 0s connected by logical ANDs, ORs and NOTs, which is nearly trivial to evaluate. It may take a few lines on a piece of paper and a few seconds of thought, but it's certainly not difficult.

without knowing values for the variables you specified, reducing it to a boolean statement is not possible. If you were to give a value to the variables (and you would have to define the symbols you use, but I understand it to be the C programming language, so I'll grant you that) reducing it to a single truth value is quite easy.

Your if statement is long, and deciding if the conditions you are using are the proper ones in the context of your program may be difficult, evaluating it, however, is not.
 

Pennstate

Diamond Member
Oct 14, 1999
3,211
0
0
Actually that was a quite specific homework problem. Pull certain atomic coordinates out of a pdb file. Although that was a long "if" statement, my program was the shortest of all. I actually thought about using case statements but it would actually mean longer codes. I am not a comp sci person so I am not caught up on efficient codes thingy. As long as it works for my homework.