HOMEWORK 2.
=============
1. Exercise 2.1 (from the book).
Say whether the following goals would succeed, and which variables, if
any, would be instantiated to what values:
pilots(A,london) = pilots(london,paris)
point(X,Y,Z) = point(X1,Y1,Z1)
letter(C) = word(letter)
noun(alpha) = alpha
'vicar' = vicar
f(X,X) = f(a,b)
f(X,a(b,c)) = f(Z,a(Z,c)).
==============
2. Write a predicate that accepts a list and succeeds if that list has
exactly three elements.
=============
3. Write a predicate that accepts a list and generates from it a similar
list with the first two elements swapped.
It should work like this:
?-swap_first_two([a,b,c,d], [b,a,c,d]).
Yes
?-swap_first_two([a,b,c,d], X).
X= [b,a,c,d];
No
?-swap_first_two(X, [b,a,c,d]).
X=[a,b,c,d];
No
?-swap_first_two([a,b,c,d], [b,a,d,c]).
No
?-swap_first_two([a,b,c,d], [X,Y,c,d]).
X=b
Y=a;
No
====================
4. Exercise 3.1 from the book:
You have the program:
aless(X,Y):-name(X,L), name(Y,M),alessx(L,M).
alessx([],[_|_]).
alessx([X|_],[Y|_]):-X