【问题标题】:CLIPS constant compiler directiveCLIPS 常量编译器指令
【发布时间】:2014-04-16 19:47:15
【问题描述】:

类似于 C 中常量的编译器指令,有没有办法可以在 CLIPS 中执行以下操作?

#define INFINITY 1000000000

(deftemplate foo
    (slot num (type INTEGER) (default INFINITY))
)

...

(defrule bar
    (foo (num INFINITY))
    =>
    ...
)

【问题讨论】:

    标签: expert-system clips compiler-directives


    【解决方案1】:

    您可以定义一个全局变量并将其视为常量:

    CLIPS> (defglobal ?*INFINITY* = 1000000000)
    CLIPS> 
    (deftemplate foo
        (slot num (type INTEGER) (default ?*INFINITY*)))
    CLIPS> 
    (defrule bar
       (foo (num ?num&:(eq ?num ?*INFINITY*)))
       =>)
    CLIPS> (assert (foo))
    <Fact-1>
    CLIPS> (facts)
    f-0     (initial-fact)
    f-1     (foo (num 1000000000))
    For a total of 2 facts.
    CLIPS> (agenda)
    0      bar: f-1
    For a total of 1 activation.
    CLIPS> 
    

    【讨论】:

      猜你喜欢
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-26
      • 1970-01-01
      • 2017-01-07
      • 2012-09-06
      • 1970-01-01
      相关资源
      最近更新 更多