Say I have a list of PROLOG facts, which are Blog Post titles, the author, and the year they were written:
blogpost('Title 1', 'author1' 2012).
blogpost('Title 2', 'author1', 2011).
blogpost('Title 3', 'author1' 2010).
blogpost('Title 4', 'author1', 2006).
blogpost('Title 5', 'author2' 2009).
blogpost('Title 6', 'author2', 2011).
I want to write a rule which has two parameters/inputs, the author, and the year. If the author entered has written an article after the specified year, PROLOG would return true
.
Here is what I have tried:
authoredAfter(X,Z) :-
blogpost(_,X,Z),
So if I queried ?- authoredAfter('author1',2010).
PROLOG would return true
because the Author has written an article in 2010. However, if I query ?- authoredAfter('author1',2009).
, it would return false
, but I want it to return true
because author1 has written an article after that year.
My question is, how do I compare the user input value to the value in the fact?