% Program: climbing.pl
% Source: Prolog
%
% Purpose: This is a solution to the climbing.pl exercises in the COMP9414/9814 lab.
% See lab.html for a full description.
%
% History: 30-Mar-1999 Original code Barry Drake
% 05-Nov-2006 SWI Prolog Bill Wilson
% Checked - let Bill W know about any further problems
% male & female
%
male(person('Will', 'Bilson')).
male(person('Jim', 'Fried')).
female(person('Dot', 'Kanga')).
% climb(Name, Grade, FirstAscentPerson, FirstAscentDate).
%
climb('Happy Go Lucky', 15, person('Will', 'Bilson'), date(11, 9,1996)).
climb('High'n'Dry', 16, person('Jim', 'Fried'), date(11, 9,1996)).
climb('Roller', 21, person('Will', 'Bilson'), date(15, 9,1996)).
climb('Naturally', 14, person('Will', 'Bilson'), date(11,10,1997)).
climb('The Picnic', 10, person('Dot', 'Kanga'), date(14, 2,1953)).
% This query would find the climbs first climbed by Will Bilson
%
% ?- climb(Name, _, person('Will', 'Bilson'), _).
% This query would find the climbs first climbed by a female
%
% ?- climb(Name, _, Person, _), female(Person).
% later(Date1, Date2) Date1 is later than Date2
%
later(date(Day1, Month, Year), date(Day2, Month, Year)) :- !,
Day1 > Day2.
later(date(_, Month1, Year), date(_, Month2, Year)) :- !,
Month1 > Month2.
later(date(_, _, Year1), date(_, _, Year2)) :-
Year1 > Year2.
% This query would find the climbs which were first climbed before 'High'n'Dry'
%
% ?- climb('High'n'Dry', _, _, HighDate),
% climb(Name, _, _, ClimbDate),
% later(ClimbDate, HighDate).