【发布时间】:2021-10-26 01:58:27
【问题描述】:
编写定义谓词 notSortedDescending(Numberlist) 的 Prolog 代码,当且仅当数字列表 Numberlist 未按降序排序时为真?
谁能帮我解决这个问题?我只知道如何在 Prolog 中编写排序函数。非常感谢!
notSortedDescending([x , y | z ]) :-
( x => y ) -> notSortedDescending([y|z])
这就是我想出的......
【问题讨论】:
-
这在很多方面都是错误的。先完成教程。
-
逻辑似乎是对的,但是你需要学习prolog语法。当测试失败时,
->/2失败。所以你可能需要写.. -> .. ; true。