comparison testing relationships

Values can be tested using five basic comparison operations <, <=, >, >= and is.

Equality comparisons

Notice that the is operator is not written =, because = is used to set variables, not test values:

if x is 6
  write 'x is 6'
  write 'x isnt 6'

If the program had been written with = instead of is, it would have set x to 6 instead of testing it.

Inequality comparisons

The less-than operator < and greater-than operator > test for values that are unequal:

if 3 < PI
  write '3 is less than PI'

The less-than-or-equal-to operator <= and greater-than-or-equal-to operator >= also allow values to be equal:

if x >= 25
  write 'no less than 25'

Comparing strings

Words or other strings of characters can be compared. They are compared according to their unicode values, which is similar to alphabetic order, but capital letters all come before lowercase letters, and numbers and other symbols also have a specific order.

a = "apple"
b = "apricot"

if a < b
  write a, 'then', b
  write a, 'after', b