Decision diagram for the SWI-Prolog "pseudo-types"

It seems SWI-Prolog is your Mr. Nobody. Well a ratio is the
result of rdiv/2, which is a form of division. And in SWI-Prolog
there is also a flag to use (/)/2 for this form of division:

SWI-Prolog (threaded, 64 bits, version 8.1.29)

?- X is 3 rdiv 4.
X = 3r4. 

?- X is 3/4.
X = 0.75.

?- set_prolog_flag(prefer_rationals, true).
true.

?- X is 3/4.
X = 3r4. /* this is a ratio, result of division */

This is brand new stuff in SWI-Prolog. It was partially discussed in
this thread Proper rational numbers (prototype for testing) few
months ago. But it is quite likely that novel stuff is lesser known.

1 Like