Wednesday, 12 November 2003

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)

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!

No time

Wednesday, 12 November 2003 18:01
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)

I keep meaning to leave the house on time, but it's often 9 before I walk out of the door. This means that I work late, and sometimes don't come home till twenty to nine or so. I feel as if I have no time.

I need to start getting a better hold on my work and play habits.

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)

Reading /friendsfriends is an amusing, yet harmless, pastime.

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 Monday, 5 January 2026 10:53
Powered by Dreamwidth Studios