Write a list of facts that are points on a graph (ex: point(1,3).)
Write a rule that determines whether a line going through 2 points is horizontal. A Horizontal line requires that the Y value be the same. The X value must be different.
Write another rule that determines whether a line going through 2 points is vertical.
Save the file with a .pl extension.
Open a prolog session on panther (swipl)
consult your knowledgebase by typing [your filename without the .pl].
list the knowledgebase using : listing.
Run a query to see all the points in your knowledgebase that start with X=1.
Run a query to test two points in your knowledgebase
Run these queries that show all the possible horizontal lines made with the points in the database: horizontal (X1,Y1,X2,Y2). . Repeat for vertical (X1,Y1,X2,Y2).
Comments
Leave a comment