CSc 404 Assignment 5
Your New Uniform
Create a prolog relation which takes an item and a list and asserts that
all members of the list are the indicated item. Place it in a text file
with ending .pl so it can be consulted.
Like so:
?- consult(inc).
true.
?- isall(eek,[eek,eek,eek,eek]).
true ;
false.
?- isall(hay,[hay,hay,hay,hay,needle,hay,hay]).
false.
?- isall(foo,[bar]).
false.
?- isall(X,[a,a,a,a,a]).
X = a.
?- isall(b,[b,b,Z]).
Z = b.
?- isall(X,[c,c,c,c,Y,c]).
X = Y, Y = c.
?- isall(www,[]).
true.
?- isall([a,b,c],[[a,b,c],[a,b,c]]).
true.
?- isall(P,[a,a,P,b]).
false.
?- isall(q,X).
X = [] ;
X = [q] ;
X = [q, q] ;
X = [q, q, q] ;
X = [q, q, q, q] ;
X = [q, q, q, q, q] .
?-
Note that on the last one, the system was offering additional
solutions, but I told it to stop.
Submission
When your function works, is nicely formatted and documents,
submit it using
this
form.