I'm trying to determine which implementation of member is more efficient by drawing the back-chaining procedure of both.
Standard Implementation:
isMember(X,[X|Tail]).
isMember(X,[H|Tail]) :- isMember(X,Tail).
Append Implementation: (From my class notes)
appendMember(X,List).
appendMember(X,List) :- myAppend(List1,[X|List2],List).
myAppend([],List,List).
myAppend([H|List1],List2,[H|Result]) :- myAppend(List1,List2,Result).
When I use the tracer on TK Eclipse I get the expected output for the standard implementation with the recursive calls but the append implementation just exits successfully immediately.
I'm wondering why that is and how to go about drawing the back-chaining procedure for the append method.
Thanks in advance!
appendMember(X,List).
is satisfied immediately, no matter what you have for the 2 arguments, since they are unconnected, uninstantiated variables.
As such, I think you should remove it.