% month(Name, Days, Next) when Name has Days days and is followed by Next. month(jan, 31, feb). month(feb, 29, mar):-leapyear,!. month(feb, 28, mar). month(mar, 31, apr). month(apr, 30, may). month(may, 31, jun). month(jun, 30, jul). month(jul, 31, aug). month(aug, 31, sep). month(sep, 30, oct). month(oct, 31, nov). month(nov, 30, dec). month(dec, 31, jan). % month(X,_,_) will list months in order % month(X,D,_) will give the days for month X % month(X,_,N) will give the next month after X % --------------or--------------- % month_days(Name, Days) and when Name has Days days. % month_next(Name, Next) and when Name is followed by Next. month_days(feb, 29):-leapyear,!. month_days(feb, 28). month_days(M, 31):-member(M, [jan, mar, may, jul, aug, oct, dec]). month_days(M, 30):-member(M, [apr,jun,sep,nov ]). month_next(jan, feb). month_next(feb, mar). month_next(mar, apr). month_next(apr, may). month_next(may, jun). month_next(jun, jul). month_next(jul, aug). month_next(aug, sep). month_next(sep, oct). month_next(oct, nov). month_next(nov, dec). month_next(dec, jan). % month_next(X,_) will list months in order % month_days(X,D) will give the days for month X % month_next(X,N) will give the next month after X