2 Replies - 1943 Views - Last Post: 16 July 2014 - 03:55 AM

#1 leibniz76   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 89
  • Joined: 02-May 14

the meaning of if ... then in computer science

Posted 16 July 2014 - 02:00 AM

I'm only familiar with one type of coding language, VBA for excel, and as far as I know the meaning of "if ... then" in that computing language is that it is not truth functional like the and or nor nand operators are. In that language if ... then meanings if you have a certain condition then you do something else. if ... then in computing languages does not have the same as it does in philosophical language where it is interpreted as:

T -> T = T
F -> T = T
F -> T = T
T -> F = F

However, since I'm only familiar with one language I want to get additional verification of this.

Is This A Good Question/Topic? 0
  • +

Replies To: the meaning of if ... then in computer science

#2 cfoley   User is offline

  • Cabbage
  • member icon

Reputation: 2392
  • View blog
  • Posts: 5,025
  • Joined: 11-December 07

Re: the meaning of if ... then in computer science

Posted 16 July 2014 - 03:10 AM

No. The philosophical thing you posted looks like a logical OR to me.

If ... else in most languages is for flow control.

// This does A
if true
  do A
else
  do B

// This does B
if false
  do A
else
  do B


Most languages have something similar that conditionally evaluates expressions. Often it's called the ternary operator but some languages (like SML and LISP) use an if syntax. The one everybody uses is the IF function in Excel. Here is the ternary operation in action

// a will be 1
a = true ? 1 : 2

// a will be 2
a = false ? 1 : 2

Was This Post Helpful? 1
  • +
  • -

#3 leibniz76   User is offline

  • D.I.C Head

Reputation: -11
  • View blog
  • Posts: 89
  • Joined: 02-May 14

Re: the meaning of if ... then in computer science

Posted 16 July 2014 - 03:55 AM

I got the truth table wrong. I meant:

T -> T = T
F -> T = T
F -> F = T
T -> F = F
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1