如何修改有序(非模板)事实,说n个值?

发布于 2025-02-10 07:48:24 字数 470 浏览 0 评论 0原文

修改不起作用。我希望事实1是(Axyz)

此外,如果我想更改事实1的第二个元素 c g ,即新事实应该是(abgd)是有一种方法使用修改?
摘要附在下面。

CLIPS> (assert (a b c d))

<Fact-1>

CLIPS> (bind ?s x y z)

(x y z)

CLIPS> (facts)

f-1     (a b c d)

For a total of 1 fact.

CLIPS> ?s

(x y z)

CLIPS> (modify 1 (implied ?s))

FALSE

CLIPS> (facts)

f-1     (a b c d)

For a total of 1 fact.

CLIPS> 

modify is not working. I expected fact 1 to be (a x y z).

Further, if I want to change the second element c of the fact 1 to say g, i.e the new fact should be (a b g d) is there a way using modify ?
Snippet attached below.

CLIPS> (assert (a b c d))

<Fact-1>

CLIPS> (bind ?s x y z)

(x y z)

CLIPS> (facts)

f-1     (a b c d)

For a total of 1 fact.

CLIPS> ?s

(x y z)

CLIPS> (modify 1 (implied ?s))

FALSE

CLIPS> (facts)

f-1     (a b c d)

For a total of 1 fact.

CLIPS> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心在旅行 2025-02-17 07:48:24

修改仅适用于模板事实。如果您使用有序事实,则需要进行缩回并断言:

CLIPS> (assert (a b c d))
<Fact-1>
CLIPS> (bind ?s x y z)
(x y z)
CLIPS> (retract 1)
CLIPS> (assert (a ?s))
<Fact-2>
CLIPS> (facts)
f-2     (a x y z)
For a total of 1 fact.
CLIPS> 

使用替换$函数在多场值中替换值,然后再将其作为事实的一部分:

CLIPS> (bind ?s (replace$ ?s 2 2 g))
(x g z)
CLIPS> 

Modify only works with template facts. If you're using ordered facts, you need to do a retract and assert:

CLIPS> (assert (a b c d))
<Fact-1>
CLIPS> (bind ?s x y z)
(x y z)
CLIPS> (retract 1)
CLIPS> (assert (a ?s))
<Fact-2>
CLIPS> (facts)
f-2     (a x y z)
For a total of 1 fact.
CLIPS> 

Use the replace$ function to replace values in a multifield value before asserting it as part of a fact:

CLIPS> (bind ?s (replace$ ?s 2 2 g))
(x g z)
CLIPS> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文