Next: Remaining Topics Up: List Processing Previous: List Processing

Exercises

1. What are the bindings which result from the following queries. If there is more than one solutin, given the order in which they are returned:


   ?- [First, Second|Rest] = [cabbage, onion, tomato, orange]

   ?- [small(X), small(Y)] = [small(cabbage), small(tomato)]

   ?- [First, Second|Rest] = [a,b]

   ?- member(small(X), [large(cabbage), small(tomato)]).

   ?- member(small(carrot), [large(Y), small(Y)]).
 
   ?- member(large(X), [large(apple), large(banana)]).

   ?- member([X,Y], [[1,2],[3,4],[5,6]]).

If you don't know, guess, then try using Prolog. If you still don't understand, try rereading notes or Bratko. If it is still baffling email me!


alison@
Fri Aug 19 10:42:17 BST 1994