self
a well-formed Ratio (i.e. parsable via to_r
)assert "123".is_r
assert "-123".is_r
assert "1/2".is_r
assert "-1/2".is_r
assert not "-1/-2".is_r
assert not "0b1011".is_r
assert not "123u8".is_r
assert not "Not an Ratio".is_r
# Is `self` a well-formed Ratio (i.e. parsable via `to_r`)
#
# assert "123".is_r
# assert "-123".is_r
# assert "1/2".is_r
# assert "-1/2".is_r
# assert not "-1/-2".is_r
# assert not "0b1011".is_r
# assert not "123u8".is_r
# assert not "Not an Ratio".is_r
fun is_r: Bool do
var frac = split_once_on('/')
if frac.length == 2 then
return frac[0].is_bi and frac[1].is_dec
else
return is_bi
end
end
lib/gmp/gmp.nit:48,5--65,7