Hi, I'm still figuring out how prolog really works and was trying to develop an small test program with an if statment but can't really get the value I need out.
prog(Sx,Sy) :-
Sx > 0 ->
update(Sx,10,S1), update(S1,10,S2), prog(S2,S2) ;
Sy.
update(S,V,RES) :-
RES is S-V.
I want prog to give Sy as an answer instead of true so I can use this as an argument of another predicate. this code gives an error when the condition is false, I've tried doing:
prog([],[],Sy).
prog(Sx,Sy) :-
Sx > 0 ->
update(Sx,10,S1), update(S1,10,S2), prog(S2,S2) ;
prog([],[],Sy).
But just returns true.
Can anybody tell me how to make it return Sy?
Thanks