instantiation-error

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

此生再无相见时 提交于 2019-12-21 08:01:10
问题 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

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

喜夏-厌秋 提交于 2019-12-04 02:57:45
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? CapelliC A Prolog predicate is a relation between arguments, and your statement the element at position P of List1 and List2 are equal is clearly an example where multiple solutions

Instantiation issue when solving this Prolog Caliban problem

时光总嘲笑我的痴心妄想 提交于 2019-12-02 07:54:11
问题 I am trying to solve the following Caliban problem using Prolog: Brown, Clark, Jones and Smith are 4 substantial citizens who serve their community as achitect, banker, doctor and lawyer, though not necessarily respectively. Brown, who is more conservative than Jones but more liberal than Smith, is a better golfer than the men who are younger than he is and has a larger income than the men who are older than Clark. The banker, who earns more than the architect, is neither the youngest nor the

Prolog - Arguments are not sufficiently instantiated

荒凉一梦 提交于 2019-11-30 00:43:42
问题 I am writing a little program which counts how many elements in a list are not numbers. Here is my code: not_number([],0). not_number([X|T],R):- not(number(X)), R1 is R+1, not_number(T,R1). not_number([_|Tail],Result):- not_number(Tail,Result). If I execute code like this : ?- not_number([1,2,3,5], R). I am getting that R = 0 (as it should be) R = 0. But if I put a character in the list: ?- not_number([1,2,3,5,a], R). then I am getting this error: ERROR: not_number/2: Arguments are not