/* Conversion Celsius <-> Fahrenheit in Picat. This is a standard example showing the reversibility of Constraint Programming (etc), here a single predicate converts from Celsius to Fahrenheit or from Fahrenheit to Celsius. This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. import mip. main => go. go => C1 = 0.0, convert(C1,F1), println([C1,F1]), F2 = 100.0, convert(C2,F2), println([C2,F2]), nl. go2 => foreach(C in -10..10) convert(C,F), println([C,F]), nl end, nl. % find integer values of C and F go3 => C :: -100..100, F :: -100..100, convert(C,F), println([C,F]), % fail, nl. convert(C,F) => C * 9.0 #= (F - 32.0) * 5.0, solve([C,F]).