首页 > 解决方案 > 使用自定义比较器 CLIPS 对函数剪辑进行排序

问题描述

使用我的比较器的排序功能给了我这种排序(Fact-57 Fact-58 Fact-59 Fact-60)。

要排序的事实是: 排序

比较器:

(deffunction MAIN::rating-sort (?f1 ?f2)
   (if (< (fact-slot-value ?f1 sum-certainties) (fact-slot-value ?f2 sum-certainties)) then return TRUE
   else (if (> (fact-slot-value ?f1 sum-certainties) (fact-slot-value ?f2 sum-certainties)) then return FALSE
        else (if (> (fact-slot-value ?f1 total-price) (fact-slot-value ?f2 total-price)) then return TRUE
             else (if (< (fact-slot-value ?f1 total-price) (fact-slot-value ?f2 total-price)) then return FALSE
                  else return FALSE)))))

代码:

(bind ?facts (find-all-facts ((?f alternative)) TRUE))
   (bind ?facts (sort rating-sort ?facts))
   (printout t ?facts crlf)

我不明白为什么它不订购它们...

预期结果:(Fact-57 Fact-59 Fact-58 Fact-60)

标签: clips

解决方案


推荐阅读