Search code examples
if-statementjess

If clause in Jess


Could some one please help me using a if clause in jess, I know the simple sintax but I'm trying to use an && operand so I can use two conditions, but nothing I try seems to work.

if((<(?x ?y) && (>=(?z ?s)) then
  ....
else
....

Solution

  • Jess has a very regular syntax which is quite unlike the Java syntax you're trying to emulate. All "operators" are actually functions, and use the same prefix syntax as function calls. It's always (op arg1 arg2 ...). The parentheses always surround the whole expression, not just the arguments.

    So for example, the Java expression a < b is always (< ?a ?b) in Jess. There is no && operator, but rather, there is an and function. So the Java if (a < b && c > d) ... looks like (if (and (< ?a ?b) (> ?c ?s)) then ... in Jess.