Write predicates one converts centigrade temperatures to Fahrenheit, the other checks if a temperature is below freezing.
๐ป Solution
week2.pl% Production rules:
c_to_f
f is c * 9 / 5 + 32
freezing f < = 32
% Rules:
c_to_f(C,F) :-
F is C * 9 / 5 + 32.
freezing(F) :-
F =< 32.
๐ค Output
w2.txt% Queries :
?- c_to_f(100,X).
X = 212
Yes
?- freezing(15).
Yes
?- freezing(45).
No