Advertisement
obernardovieira

An Excellent Driver (day 1) [SLiSW]

Jul 29th, 2015
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.27 KB | None | 0 0
  1. /*First time with prolog. It looks good*/
  2. %first exercise
  3. %----------lib.pl-----------------
  4. books(book1, writerA).
  5. books(book1, writerB).
  6. books(book2, writerB).
  7. books(book3, writerC).
  8. books(book4, writerA).
  9. books(book5, writerD).
  10. books(book6, writerE).
  11. books(book7, writerB).
  12. books(book8, writerE).
  13. books(book9, writerC).
  14. books(book10, writerF).
  15. books(book11, writerA).
  16. books(book12, writerB).
  17. books(book13, writerB).
  18. books(book14, writerC).
  19. books(book15, writerD).
  20. books(book16, writerE).
  21. %-------------------------------
  22. /*then in command line is like this
  23. ?- ['lib.pl'].
  24. % lib.pl compiled 0.00 sec, 16 clauses
  25. true.
  26.  
  27. ?- books(What, writerA).
  28. What = book1 ;
  29. What = book4 ;
  30. What = book11.
  31. */
  32.  
  33. %exercise 2
  34. %-------------------music.pl----------------
  35. singer(singerA, rock).
  36. singer(singerB, metal).
  37. singer(singerC, rb).
  38. singer(singerD, jazz).
  39. singer(singerE, latin).
  40.  
  41. instrument(singerA, guitar).
  42. instrument(singerA, piano).
  43. instrument(singerB, guitar).
  44. instrument(singerC, piano).
  45. instrument(singerD, saxophone).
  46. instrument(singerC, guitar).
  47. %---------------------------------------
  48. /*command line
  49. ?- ['music.pl'].
  50. % music.pl compiled 0.00 sec, 7 clauses
  51. true.
  52.  
  53. ?- instrument(Who, guitar).
  54. Who = singerA ;
  55. Who = singerB ;
  56. Who = singerC.
  57. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement