Simple prolog program. Getting error: >/2: Arguments are not sufficiently instantiated
问题 I made a Prolog predicate posAt(List1,P,List2) that tests whether the element at position P of List1 and List2 are equal: posAt([X|Z], 1, [Y|W]) :- X = Y. posAt([Z|X], K, [W|Y]) :- K > 1, Kr is K - 1, posAt(X, Kr, Y). When testing: ?- posAt([1,2,3], X, [a,2,b]). I expected an output of X = 2 but instead I got the following error: ERROR: >/2: Arguments are not sufficiently instantiated Why am I getting this error? 回答1: A Prolog predicate is a relation between arguments, and your statement the