2025-04-16 04:23:48 +00:00
|
|
|
import {ReturnsAs} from './helpers.js'
|
2025-04-25 14:17:34 +00:00
|
|
|
import {ResolutionError} from '#core/helpers.js'
|
|
|
|
import {Passthru, match} from '#core/TypePatterns.js'
|
|
|
|
import {boolnum} from '#number/helpers.js'
|
2025-04-16 04:23:48 +00:00
|
|
|
|
2025-04-25 14:17:34 +00:00
|
|
|
// Most types are real. Have to make sure to redefine on all non-real types
|
|
|
|
export const isReal = match(Passthru, boolnum(() => true))
|
2025-04-24 00:16:04 +00:00
|
|
|
export const isZero = match(Passthru, (math, [T]) => {
|
2025-04-16 04:23:48 +00:00
|
|
|
if (!T) { // called with no arguments
|
|
|
|
throw new ResolutionError('isZero() requires one argument')
|
|
|
|
}
|
|
|
|
const z = math.zero(T)
|
|
|
|
const eq = math.equal.resolve([T, T])
|
|
|
|
return ReturnsAs(eq, x => eq(z, x))
|
2025-04-24 00:16:04 +00:00
|
|
|
})
|