pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
[personal profile] pne

I had a test in a program I'm writing which tested three truth values; let's call them A, B, and C. At the moment, it's testing for A && B && C (that is, they all have to be true at once).

After debugging, I realise that that's not what I want; I actually want the test to be "if A, then if B then also C" [but if A and not-B, then I don't care about C], but I wasn't sure how to express an "if" relationship with logical operators.

Enter Lojban :) I remembered that "logical if" as in "if X, then Y" is "ganai X gi Y". Translated back into logics, that's "not-X or Y". (For the curious who are not familiar with Lojban, the "a" bit of "ganai" is responsible for the "or" meaning, and the "nai" bit for the "not" meaning. The "g" of "ganai", as well as the word "gi", are used for all forethought logical connectives.)

After a quick sanity check I realised that this is what I wanted—if A is true, and either B is not true or [B is true and] C is true, then the bit of code should be executed. Changed "if (A && B && C)" to "if (A && (!B || C))" and away I went!

(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
Philip Newton

June 2015

S M T W T F S
 12 3456
78910111213
14151617181920
2122232425 2627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Friday, 2 January 2026 04:39
Powered by Dreamwidth Studios