The problem continues regardless of refactoring, but it changes, if I switch line 6 and 7 I get different results? How could that even be possible?
If relevent this is gnuprolog on a MacOS Monterey (version 12.6.2) device.
Here is the relevent code:
conversion(meters, 82/25, feet).
conversion(feet, 12/1, in ).
conversion(hr, 60/1, min ).
conversion(min, 60/1, sec ).
conversion(Unit1, X/Y, Unit2) :- conversion(Unit2, Y/X, Unit1), !.
conversion(Unit1, Num/Den, Unit3) :- conversion(Unit1, X/Y, Unit2), conversion(Unit2, A/B, Unit3), Num is X * A, Den is Y*B.
Whever I enter a question that requires more then a single inversion (as in the second to last rule) I get an error. So,
conversion(meters,X,in).
conversion(hr,X,sec).
conversion(in, X, meters).
Cause,
Fatal Error: local stack overflow (size: 16384 Kb, reached: 16384 Kb, environment variable used: LOCALSZ)
But
conversion(min,X,hr).
conversion(feet,X,meters).
Produce the expected results. Any wisdom would be greatly appreciated!
The following appears to work, thanks @brebs!