0
我努力正確評估多字段值的整數值。CLIPS:如何評估作爲整數的多字段值
最終,我需要的是模式匹配一個只包含整數的多槽,並能夠判斷「列表」是否按升序排列。
我有什麼至今:
(defclass status
(is-a USER)
(role concrete)
(pattern-match reactive)
(multislot numbers
(create-accessor write)
(type INTEGER)
(range 1 ?VARIABLE)
(default 1)
)
)
(defrule asc
?st <- (object (is-a status) (numbers $?n))
(test (> (length ?n) 2))
(test (< (first$ ?n) (rest$ ?n)))
=>
(printout t "List " ?n " is ascending" crlf)
)
(make-instance of status (numbers 1 2 3))
我明白,也許這不是擴大多時隙並填充爲(<)參數的方式,但我似乎無法找到正確的方式。 即使參數擴展正確,但它仍然表示,它需要一個整數參數,但
(first$ ?n)
不計算爲整數。
我的問題是: 如何獲取值列表的值並將其「解析」爲整數? 其次,我該如何擴展這些值以使它們的參數(<)並確定列表是否按升序排列?