Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*First time with prolog. It looks good*/
- %first exercise
- %----------lib.pl-----------------
- books(book1, writerA).
- books(book1, writerB).
- books(book2, writerB).
- books(book3, writerC).
- books(book4, writerA).
- books(book5, writerD).
- books(book6, writerE).
- books(book7, writerB).
- books(book8, writerE).
- books(book9, writerC).
- books(book10, writerF).
- books(book11, writerA).
- books(book12, writerB).
- books(book13, writerB).
- books(book14, writerC).
- books(book15, writerD).
- books(book16, writerE).
- %-------------------------------
- /*then in command line is like this
- ?- ['lib.pl'].
- % lib.pl compiled 0.00 sec, 16 clauses
- true.
- ?- books(What, writerA).
- What = book1 ;
- What = book4 ;
- What = book11.
- */
- %exercise 2
- %-------------------music.pl----------------
- singer(singerA, rock).
- singer(singerB, metal).
- singer(singerC, rb).
- singer(singerD, jazz).
- singer(singerE, latin).
- instrument(singerA, guitar).
- instrument(singerA, piano).
- instrument(singerB, guitar).
- instrument(singerC, piano).
- instrument(singerD, saxophone).
- instrument(singerC, guitar).
- %---------------------------------------
- /*command line
- ?- ['music.pl'].
- % music.pl compiled 0.00 sec, 7 clauses
- true.
- ?- instrument(Who, guitar).
- Who = singerA ;
- Who = singerB ;
- Who = singerC.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement