Do exercise 6 on page 384 by completing the Java program
ParameterTest.java in $CLASSHOME/src/homework10/:
but skip 6(d) (macro expansion).
Answer the following questions in a file README:
Solve Exercises 10,11 on page 415. Also define a predicate
mingle that takes three arguments and returns true if the
third can be created by mingling the elements of the first two
together while preserving relative order:
?- mingle([1,2],[3],[3,1,2]). Yes ?- mingle([1,2],[3],[1,3,2]). Yes ?- mingle([1,2],[3],[3,2,1]). No ?- mingle(X,Y,[1,2]). X = [1, 2] Y = [] ; X = [1, 2] Y = [] ; X = [1, 2] Y = [] ; X = [1] Y = [2] ; X = [2] Y = [1] ; X = [2] Y = [1] ; X = [] Y = [1, 2] ; No
As this example shows, it is permitted to yield the same results more
than once. Also, you can assume that either the first or the last
argument is a fixed length list.
The code for mingle as well
as the answers to Exercises 10 and 11 should go into
homework10.pl
in your homework10 directory of your AFS volume.