17 lines
513 B
Plaintext
17 lines
513 B
Plaintext
create or replace function number_integerp(x) as (
|
|
x = trunc(x)
|
|
);
|
|
|
|
# Return true iff x has the type signature of a Rational
|
|
# with the denominator dividing the numerator evenly.
|
|
create or replace function rational_integerp(x) as (
|
|
typeof(x) = 'STRUCT(n INTEGER, d INTEGER)'
|
|
and x.n % x.d = 0
|
|
);
|
|
|
|
# Return true if x can be cast to a Complex with
|
|
# the imaginary part equal to 0 and an integer real part.
|
|
create or replace function complex_integerp(x) as (
|
|
(x::Complex).i = 0 and number_integerp(x.r)
|
|
);
|