How to generalize program according to arity in prolog?

断了今生、忘了曾经 提交于 2019-12-02 11:43:25

putting all the arguments in a list like

attribute([a1,a2,a3,a4,a5,a6]).
data([yes,yes,yes,no,no,no]).
data([yes,yes,yes,no,no,yes]).

and then recursively process the data is what I would do.

if, for some reason, you want to have predicates with different arities, you could use the =../2 operator to get the arguments in a list and then process them

or you can write code for each arity XD

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!