Structure in Prolog : An Intro to Data Structures

C Structure to store employee data
Prolog facts for creating a structure representing information about books
  1. Determine the title and author of a book given, the ISBN number of the book
    ?-book(title(X),author(Y),isbn(1234567898767)).

    In the above query two of the three attributes from the structure are left with variables X and Y only a single attribute i.e. the ISBN number is mentioned. Therefore, when this query is fired the knowledge base will be traversed for a record with the matching ISBN number and the corresponding title and author will be returned. As simple as that.
  2. Determine the author and ISBN number of the book wings of fire.
    ?-book(title(wings_of_fire),author(Y),isbn(Z)).
    Quite similar to the previous query here in, the knowledge base will be traversed against the given title and the corresponding author and ISBN number.
  3. Display the details of all the books stored in the knowledge base.
    ?-book(title(X),author(Y),isbn(Z)).
  4. Display all the books written by Ruskin Bond.
    ?-book(title(X),author(ruskin_bond),isbn(Z)).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store