Order of rules matters!
mem1(X,[X|_]).
mem1(X,[_|T]) :- mem1(X,T).
versus
mem2(X,[_|T]) :- mem2(X,T).
mem2(X,[X|_]).
Which is more efficient?
Previous slide
Next slide
Back to first slide
View graphic version