Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
logical operators Q
#1
Not 100% sure if conversions are correct.
Are they?

Code:
AND:
IF a AND b THEN
c
END IF
------
IF "a" THEN
IF "b" THEN
c
END IF
END IF

OR:
IF a OR b THEN
c
END IF
------
IF a THEN
c
ELSE
IF b THEN
c
END IF
END IF

XOR:
IF a XOR b THEN
c
END IF
------
IF a THEN
IF NOT b THEN
c
END IF
ELSE
IF b THEN
c
END IF

EQV:
IF a EQV b THEN
c
END IF
------
IF a THEN
IF b THEN
c
END IF
ELSE
IF NOT b THEN
c
END IF

IMP:
IF a IMP b THEN
c
END IF
------
IF a THEN
c
END IF
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
The transformations upto XOR look good. But I am not sure about the last two.
Reply
#3
this is wrong:

Code:
OR:
IF a OR b THEN
c
END IF
------
IF a THEN
c
ELSE
IF b THEN
c
END IF
END IF

It should be:

Code:
IF a THEN c
IF b THEN c
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Quote:this is wrong:

Code:
OR:
IF a OR b THEN
c
END IF
------
IF a THEN
c
ELSE
IF b THEN
c
END IF
END IF

It should be:

Code:
IF a THEN c
IF b THEN c

No, what he put is still correct, in that it will execute c when and only when using an OR would. It just is longer than it needs to be.
Reply
#5
Nevermind ... too much pot Big Grin

(in fact, somehow, I was thinking in prolog Tongue)
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
Actually your code would execute c twice.....
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#7
Quote:Actually your code would execute c twice.....

No, the ELSE clause cannot execute if the IF part does.
Reply
#8
That's right........

................
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#9
Quote:
Agamemnus Wrote:Actually your code would execute c twice.....

No, the ELSE clause cannot execute if the IF part does.

He was refering to Na_th_an's code.... :-?
Reply
#10
Quote:
PlayGGY Wrote:
Agamemnus Wrote:Actually your code would execute c twice.....

No, the ELSE clause cannot execute if the IF part does.

He was refering to Na_th_an's code.... :-?

Woops. And he is right.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)