RationalRetractions S

retract.spad line 52 [edit on github]

Rational number testing and retraction functions.

rational?: S -> Boolean

rational?(x) returns true if x is a rational number, false otherwise.

rational: S -> Fraction Integer

rational(x) returns x as a rational number; error if x is not a rational number.

rationalIfCan: S -> Union(Fraction Integer, failed)

rationalIfCan(x) returns x as a rational number, “failed” if x is not a rational number.