I have predicates monthyear that returns the current month if month and year are not supplied below.
monthyear(M,Y) :-
get_time(Stamp),
stamp_date_time(Stamp, DateTime, local),
date_time_value(month, DateTime, M),
date_time_value(year, DateTime, Y).
If month and year are supplied return supplied month and year. To achieve this i have written the following code below.
cal(X,Y,Z1,Z2):-
Z1 is X,
Z2 is Y.
cal(X,Y,Z1,Z2):-
X == null,
Y == null,
monthyear(Z1,Z2).
However i am sure this code can be improved and i am also faced with an error
ERROR: is/2: Arguments are not sufficiently instantiated
How can i go about making this work?.
X=1,Y=2,cal(X,Y,Z1,Z2).
returns
Z1 = X
Z2 = Y
and
cal(X,Y,Z1,Z2).
returns
Z1 = 1,
Z2 = 2016
== null? What do you mean with== null? - Willem Van Onsem