2025-04-16 04:23:48 +00:00
|
|
|
import {ReturnsAs} from './helpers.js'
|
2025-04-24 00:16:04 +00:00
|
|
|
import {ResolutionError, match} from '#core/helpers.js'
|
2025-04-16 04:23:48 +00:00
|
|
|
import {Returns} from '#core/Type.js'
|
2025-04-24 00:16:04 +00:00
|
|
|
import {Passthru} from "#core/TypePatterns.js"
|
2025-04-16 04:23:48 +00:00
|
|
|
|
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
|
|
|
})
|