本文介绍了如何在Prolog中传递谓词作为另一个谓词的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这3个谓词:
ceval / 2 谓词显示如何执行递归树步行。校长与制作漂亮的打印机相同。我非常懒惰,所以我只会草绘,你必须自己填写细节。
The eval/2 predicate shows you how to perform a recursive tree walk. The principal is the same with making a pretty printer. I am very lazy so I will only sketch it, you'll have to fill in the details yourself.
printterm(T) :- format_term(T, Formatted), write(Formatted), nl. format_term(plus(X,Y), Formatted) :- format_term(X, XFormatted), format_term(Y, YFormatted), format(atom(Formatted), '(~a + ~a)', [XFormatted, YFormatted]). % other format_term clauses here for other arithmetic expressions format_term(X, X) :- number(X).希望这有帮助!
这篇关于如何在Prolog中传递谓词作为另一个谓词的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!