Perfect Developer tutorial This page last modified 2004-12-17 (DC)

Operator Expressions Quiz

1. The expression >-<-4 is in very poor style but nevertheless legal in Perfect. How should it be read, and what is its value?

"Successor of minus predecessor of minus 4", or  >(-(<(-4))) , which has the value 6.


2. If it is known that x ~~ y = same@rank , which of the following can be deduced, if x and y have the same type but the ~~ operator for this type does not define a total ordering? Is the answer any different if the ~~ operator does define a total ordering?

  1. x >~ y
  2. ~(x > y)
  3. y ~~ x = same@rank
  4. ~(x < y)
  5. x = y

Expression (a) is true because it is equivalent to x ~~ y = same@rank | x ~~ y = above@rank .
Expression (b) is true because it means ~(x ~~ y = above@rank) .
Expression (c) is true because x ~~ y = same@rank and y ~~ x = same@rank are each true if and only if x and y are in the same partition.
Expression (d) is true because it means ~(x ~~ y = below@rank) .
Expression (e) may or may not be true because values in the same partition are not necessarily equal unless the ordering is total. If the ~~ operator defines a total ordering for this type, then expression (e) must be true as well.