I need to count the data between the years 2002 to recent "times". Let's imagine the last known quarter of 2014 would be quarter number 2. So then I could count Q1 and Q2 of 2014 and checkQuarter(2014,"Q3") and checkQuarter(2014,"Q4") would produce false() with the code below.
The code below produces numerous
w651 Unreachable or excessive code (removed by the optimization)
and I really can not figure why.
Code: Select all
constants
lastKnownYearInQuarters : unsigned = 2014.
lastKnownQuarter : string = "Q2".
predicates
checkQuarter:(unsigned Year, string Quarter) -> boolean.
clauses
checkQuarter(Year,_) = true():-
Year < lastKnownYearInQuarters,!.
checkQuarter(Year,Q) = true():-
Year = lastKnownYearInQuarters,
lastKnownQuarter = "Q4",
list::isMember(Q,["Q1","Q2","Q3","Q4"]),!,
checkQuarter(Year,Q) = true():-
Year = lastKnownYearInQuarters,
lastKnownQuarter = "Q3",
list::isMember(Q,["Q1","Q2","Q3"]),!.
checkQuarter(Year,Q) = true():-
Year = lastKnownYearInQuarters,
lastKnownQuarter = "Q2",
list::isMember(Q,["Q1","Q2"]),!.
checkQuarter(Year,Q) = true():-
Year = lastKnownYearInQuarters,
lastKnownQuarter = "Q1",
list::isMember(Q,["Q1"]),!.
checkQuarter(_Year,_Q) = false().