0
brand(_AbbottHill).
brand(_Manzarita).
brand(_Graffetz).
brand(_Williford).

size(4).
size(5).
size(6).
size(7).

solve:-
brand(AbbottHill), brand(Manzarita), brand(Graffetz), brand(Williford),
all_different([AbbottHill, Manzarita, Graffetz, Williford]),

size(4),size(5),size(6),size(7),
all_different([4,5,6,7]),

Triples = [ [lucia, LuciaBrand, LuciaSize],
         [genevieve, GenevieveBrand, GenevieveSize],
         [vanessa,VanessaBrand, VanessaSize],
         [shawna, ShawnaBrand, ShawnaSize]],

  (member([lucia, _ , 4], Triples),  member([Manzarita,_, 7], Triples)) ; 
  (member([ lucia,_,7], Triples),  member([ Manzarita, _, 4], Triples)),

  (((member([genevieve, _, 4], Triples),(member([ AbbottHill,_, 6], 
  Triples));(member([genevieve,_, 5],Triples),(member([ AbbottHill, _ , 7], 
  Triples))),

(((member([vanessa, _, 6], Triples),(member([ genevieve, _, 4], Triples));
(member([vanessa, _,7],Triples),(member([genevieve,_, 5], Triples))),

(member([shawna, _, 5], Triples), (member([Grafettz, _, 4], Triples));
(((member([shawna, _, 6], Triples), (member([Grafettz, _, 4], Triples); 
member([Grafettz, _, 5], Triples)));(((member([shawna, _, 7], Triples), 
(member([Grafettz, _, 4], Triples); member([Grafettz, _, 5], Triples); 
member([Grafettz, _, 6], Triples)),

tell(lucia, LuciaBrand, LuciaSize),
tell(genevieve, GenevieveBrand, GenevieveSize),
tell(vanessa, VanessaBrand, VanessaSize),
tell(shawna, ShawnaBrand, ShawnaSize),

all_different([H | T]):- member(H,T),!,fail.
all_different([_ | T]) :- all_different(T).
all_different([_]).

tell(X,Y,Z):-
write(X), write(‘bought a size '), write(Y),write(Z), write('.'),nl.

the operator error is coming from this line: all_different([H | T]):- member(H,T),!,fail. and the end of file error is coming from this line: tell(X,Y,Z):- i'm trying to get it output something like this For each customer, show their name, their shoe size and their shoe's manufacturer in a format similar to this: Joe bought a size 13 Nike.

lurker
  • 56,987
  • 9
  • 69
  • 103
Tommy Li
  • 1
  • 1
  • 1
    Please add some better indentation! Also, constants start with a lower case letter, variables with an upper case letter, thus `brand/1` currently makes no sense. Same for many further names... – false May 05 '17 at 12:42
  • The operator error is because you have an incomplete clause prior to your `all_different/1` definition (see the comma right before?). And why are you redefining an existing Prolog predicate (`all_different`)? It's not a good idea. The end of file error is probably because you have a lot of syntax errors and Prolog is getting to the end of the file containing your code before what it thinks is a complete Prolog expression or term is completely parsed. As @false says, format your code properly. That will enhance readability, which is something you need to do: read through your code carefully. – lurker May 06 '17 at 03:04
  • What's the purpose of facts such as `brand(_AbbottHill).`? `_AbbottHill` is a variable. So your four different `brand/1` facts all really say the same thing: that any valid Prolog term is a valid brand. – lurker May 06 '17 at 03:06

0 Answers0