fork(5) download
  1. houses([
  2. house(first, _, _, _, _, _),
  3. house(second, _, _, _, _, _),
  4. house(third, _, _, _, _, _),
  5. house(forth, _, _, _, _, _),
  6. house(fifth, _, _, _, _, _)
  7. ]).
  8.  
  9. right_of(A, B, [B, A | _]).
  10. right_of(A, B, [_ | Y]) :- right_of(A, B, Y).
  11.  
  12. next_to(A, B, [A, B | _]).
  13. next_to(A, B, [B, A | _]).
  14. next_to(A, B, [_ | Y]) :- next_to(A, B, Y).
  15.  
  16. mymember(X, [X|_]).
  17. mymember(X, [_|Y]) :- mymember(X, Y).
  18.  
  19. print_houses([]).
  20. print_houses([A|B]) :-
  21. write(A), nl,
  22. print_houses(B).
  23.  
  24.  
  25. where_fish(H):-houses(H),
  26. mymember(house(_,red,english,_,_,_),H),
  27. mymember(house(_,_,swedish,dog,_,_),H),
  28. mymember(house(_,_,datman,_,tea,_),H),
  29. right_of(house(_,green,_,_,_,_),
  30. house(_,white,_,_,_,_),H),
  31. mymember(house(_,green,_,_,coffe,_),H),
  32. mymember(house(_,_,_,bird,_,pallmall),H),
  33. H=[_,_,house(_,_,_,_,milk,_),_,_],
  34. mymember(house(_,yellow,_,_,_,dunhill),H),
  35. mymember(house(first,_,norway,_,_,_),H),
  36. next_to(house(_,_,_,_,_,marlboro),
  37. house(_,_,_,cat,_,_),H),
  38. next_to(house(_,_,_,horse,_,_),
  39. house(_,_,_,_,_,dunhill),H),
  40. mymember(house(_,_,_,_,bear,winfield),H),
  41. next_to(house(_,_,norway,_,_,_),
  42. house(_,blue,_,_,_,_),H),
  43. mymember(house(_,_,denmark,_,_,rothmans),H),
  44. next_to(house(_,_,_,_,_,marlboro),
  45. house(_,_,_,_,water,_),H),
  46. print_houses(H).
  47.  
  48. :-where_fish(_).
Success #stdin #stdout 0.03s 6160KB
stdin
Standard input is empty
stdout
house(first, yellow, norway, cat, water, dunhill)
house(second, blue, datman, horse, tea, marlboro)
house(third, red, english, bird, milk, pallmall)
house(forth, white, swedish, dog, bear, winfield)
house(fifth, green, denmark, _G461, coffe, rothmans)