【发布时间】:2021-06-25 08:14:03
【问题描述】:
作为 prolog 中的实践,我试图将整数列表转换为一个整数,就像我们有一个列表 [1,2,3] 然后它输出 123。这就是我目前写的:
listToNum([],_).
listToNum([H|T],Num):-
cntSize(T,Size),
N1 is Num + (H*10**Size),
listToNum(T,N1).
我收到了这个程序的评论:
Arguments are not sufficiently instantiated
In:
[2] _1626 is _1632+1* ...
[1] listToNum([1,2],_1696) at line 33
请问我可以做些什么来改进我的代码并获得适当的结果?
【问题讨论】:
-
我认为您收到了有用的答案。如果是这样,我建议你accept the answer with the best solution to your problem。
标签: prolog swi-prolog