Reputation: 101
I have this: problem(a(1,2,3),P)
And I need to get this: P = [e(1, 3), e(2, 0)]
I just started with Prolog a few days ago and I wrote this:
problem([a(X,Y,Z)],P) :- P is [e(X,Z),e(Y,0)].
But I only get a false
by answer. What error did I make?
Upvotes: 1
Views: 34
Reputation: 18663
The standard is/2
predicate is used for evaluating arithmetic expressions. In your case, a simple fact would suffice:
problem(a(X,Y,Z), [e(X,Z),e(Y,0)]).
For example:
?- [user].
problem(a(X,Y,Z), [e(X,Z),e(Y,0)]).
|: ^D
?- problem(a(1,2,3), P).
P = [e(1, 3), e(2, 0)].
Upvotes: 2