clips - 使用自定义比较器 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)
解决方案
推荐阅读
- javascript - 如何在运行时访问 JSDoc
- html - 具有 3 种水平颜色的网站正文背景
- npm - npm 和 webpack - 包大小
- flutter - 需要从 Google Places API 中获取评级数字,而不仅仅是星星
- sql - 试图总结 2 个表,其中某些条目在另一个表中不存在
- python - 我怎么能用 BeautifulSoup 分割这个?
- react-native - 在 React Native Expo 中更新状态变量
- list - Flutter ListView删除项目不起作用
- python - 使用 for 循环与嵌套 if 语句相结合,基于 Python 中不同 DataFrame 的 3 列创建新的 pandas DataFrame
- android - android.view.InflateException: Binary XML file line #5: Binary XML file line #5: Error inflating class layout