使用运算符'和'Jess

时间:2017-04-07 13:49:01

标签: operators jess

如何在Jess中正确使用运算符'和'

我的(错误)代码示例:

(test (and (>= ?x ?minx) (and (<= ?x ?maxx) (and (>= (+ ?x (- ?y1 ?y)) ?minx) (and (<= (+ ?x (- ?y1 ?y)) ?maxx) ...

另外,在if子句中,如何使用它?

感谢。

1 个答案:

答案 0 :(得分:0)

我在您的代码中添加了一些缩进,以尝试了解您正在做的事情:

(test
    (and (>= ?x ?minx)
         (and (<= ?x ?maxx)
              (and (>= (+ ?x (- ?y1 ?y)) ?minx)
                   (and (<= (+ ?x (- ?y1 ?y)) ?maxx)

最后缺少“)”但我认为这不是问题。基本上,如果你试图表达一系列条件的结合,你只需要一个and,并根据需要给它提供多个参数。所以,例如,像

这样的东西
(test
    (and (>= ?x ?minx)
         (<= ?x ?maxx)
         (>= (+ ?x (- ?y1 ?y)) ?minx)
         (<= (+ ?x (- ?y1 ?y)) ?maxx)))

if而言,the manual中已明确记录了这些内容:

(if (> ?x 100) then
    (printout t "X is big" crlf)
 elif (> ?x 50) then
    (printout t "X is average" crlf)
 else
    (printout t "X is small" crlf))