Simple prolog program. Getting error: >/2: Arguments are not sufficiently instantiated

Posted by user1279812 on Stack Overflow See other posts from Stack Overflow or by user1279812
Published on 2012-03-20T00:56:18Z Indexed on 2012/03/20 5:29 UTC
Read the original article Hit count: 194

Filed under:
|

I made a prolog program 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?

© Stack Overflow or respective owner

Related posts about prolog

Related posts about swi-prolog