


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Today ...
Be careful with variable names
r(X, Y) :- r(X, Z), s(Z, Y).
Checking list membership
member(X, [X | ]). member(X, [ | T]) :- member(X, T).
Q: What is the proof tree for member(2, [1, 2])?
Q: What is the proof tree for member(2, [1, 3])?
Note this example works like pattern matching in Haskell ...
Q: How would we write a last predicate?
last(X, [X]). last(X, [_|T]) :- last(X, T).
Q: What is the proof tree for last(2, [1, 2])?