fork download
  1. % find the Zebra and the Water, zebra_water(X).
  2. % by Willem Robert van Hage, wrvhage@science.uva.nl
  3.  
  4. right(2,1).
  5. right(3,2).
  6. right(4,3).
  7. right(5,4).
  8. nextdoor(X,Y) :- right(X,Y).
  9. nextdoor(X,Y) :- right(Y,X).
  10.  
  11. match([],_).
  12. match([X|Xs],Ys) :-
  13. member(X,Ys),
  14. match(Xs,Ys).
  15.  
  16. zebra_water(X) :-
  17. nextdoor(Horse,Diplomat),
  18. nextdoor(Fox,Doctor),
  19. nextdoor(Norwegian,Blue),
  20. Y = [house( Green, _, green, _, _, _),
  21. house( White, _, white, _, _, _),
  22. house(Norwegian, norwegian, _, _, _, _),
  23. house( Blue, _, blue, _, _, _),
  24. house( Fox, _, _, _, fox, _),
  25. house( Doctor, _, _, doctor, _, _),
  26. house( Horse, _, _, _, horse, _),
  27. house( Diplomat, _, _, diplomat, _, _),
  28. house( 3, _, _, _, _, milk),
  29. house( 1, norwegian, _, _, _, _),
  30. house( _, englishman, red, _, _, _),
  31. house( _, spaniard, _, _, dog, _),
  32. house( _, japanese, _, painter, _, _),
  33. house( _, italian, _, _, _, tea),
  34. house( _, _, yellow, diplomat, _, _),
  35. house( _, _, green, _, _, coffee),
  36. house( _, _, _, sculptor, snails, _),
  37. house( _, _, _, violinist, _, juice),
  38. house( _, _, _, _, zebra, _),
  39. house( _, _, _, _, _, water) ],
  40. X = [ house(1,_,_,_,_,_),
  41. house(2,_,_,_,_,_),
  42. house(3,_,_,_,_,_),
  43. house(4,_,_,_,_,_),
  44. house(5,_,_,_,_,_) ],
  45. right(Green,White),
  46. match(Y,X).
Success #stdin #stdout 0.02s 68352KB
stdin
Standard input is empty
stdout
GNU Prolog 1.3.1
By Daniel Diaz
Copyright (C) 1999-2009 Daniel Diaz