首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >clips:避免连接约束

clips:避免连接约束
EN

Stack Overflow用户
提问于 2019-04-24 00:06:20
回答 1查看 54关注 0票数 0

让我们假设我们有以下CLIPS模板和规则:

代码语言:javascript
复制
;; The queue sequence starts at 0.
;; -1 is a placeholder value to identify a newly inserted element.
;; The idea is to put a newly inserted element at the end of the queue.
(deftemplate queue-element
    (slot order (type INTEGER) (default -1))

(deftemplate put-at-the-end
    ?e1 <- (queue-element (order -1))
    ?e2 <- (queue-element (order ?o1))
    (not (queue-element (order ?o2&:(> ?o2 ?o1))))
  =>
    (modify ?e1 (order (+ ?o1 + 1))))

是否有一种方法可以将“连接约束”(> ?o2 ?o1)从模式中移出并将其移动到类似于(test (> ?o2 ?o1))构造的位置?

这样做的目的是为了避免这种进退两难的局面。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-24 02:13:02

可以使用条件元素将多个条件元素放置在而不是条件元素中。

代码语言:javascript
复制
CLIPS> 
(deftemplate queue-element
    (slot order (type INTEGER) (default -1)))
CLIPS> 
(defrule put-at-the-end
    ?e1 <- (queue-element (order -1))
    ?e2 <- (queue-element (order ?o1))
    (not (and (queue-element (order ?o2))
              (test (> ?o2 ?o1))))
  =>
    (modify ?e1 (order (+ ?o1 1))))
CLIPS> 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55820954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档