Result in an argument isn't correct
Posted
by
Paulo Nunes
on Stack Overflow
See other posts from Stack Overflow
or by Paulo Nunes
Published on 2011-11-30T17:48:24Z
Indexed on
2011/11/30
17:50 UTC
Read the original article
Hit count: 406
So I have this piece of prolog code: my_avalia(A,R) :- A=="Koza" ->koza(R,0,0,e,89).
koza(R,_,_,_,87):-!,write(R).
koza(R,X,Y,V,C):-movex(V,X,X1),movey(V,Y,Y1),confirma(X1,Y1,Z),Z==1->(append(R,[emFrente],U),L is (C-1),koza(U,X1,Y1,V,L)).
The matter is that when I write the "R" at koza(), it has the correct values, however it ends up with a empty list in my_avalia when I call it like this:
my_avalia("Koza",R).
My recursion might be incorrect but I don't really know what's wrong with it. Thanks in advance.
© Stack Overflow or respective owner