【问题标题】:CLIPS (Expert System) write rules that add and remove values from the queueCLIPS(专家系统)编写从队列中添加和删除值的规则
【发布时间】:2017-12-03 19:22:00
【问题描述】:

我需要帮助编写两条规则,从队列中添加和删除值。从队列中移除值的规则必须使用forall 结构。

据我所知,CLIPS 没有数组、堆栈、列表或任何其他类型的集合。所以我开始定义模板queue 和一个插槽item,它应该代表一个队列的值,但没有成功使用规则。有谁知道如何做到这一点?

【问题讨论】:

  • 请提供一些代码以增加更改以更好地理解您的问题并提供答案。

标签: clips expert-system


【解决方案1】:

CLIPS 具有充当列表的多字段对象。

您可以将队列定义为全局变量,并在您的规则中对其进行修改,如本示例(LIFO 队列)。

CLIPS> (defglobal ?*queue* = (create$))
; add "foo" to the queue
CLIPS> (bind ?*queue* (insert$ ?*queue* 1 "foo"))
("foo")
; add "bar" to the queue
CLIPS> (bind ?*queue* (insert$ ?*queue* 1 "bar"))
("bar" "foo")
; remove first element from the queue
(bind ?*queue* (delete$ ?*queue* 1 1))
("foo")

【讨论】:

    猜你喜欢
    • 2018-03-05
    • 1970-01-01
    • 2021-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2011-03-15
    相关资源
    最近更新 更多