feat: Add isReal and isZero, and fix specializing a generic type
All checks were successful
/ test (pull_request) Successful in 17s

This commit is contained in:
Glen Whitney 2025-04-25 00:08:29 -07:00
parent 627c1c3d7f
commit f9b723b882
5 changed files with 28 additions and 4 deletions

9
src/complex/utils.js Normal file
View file

@ -0,0 +1,9 @@
import {Complex} from './Complex.js'
import {match} from '#core/TypePatterns.js'
import {ReturnsAs} from '#generic/helpers.js'
export const isReal = match(Complex, (math, C) => {
const eq = math.equal.resolve([C.Component, C.Component])
const add = math.add.resolve([C.Component, C.Component])
return ReturnsAs(eq, z => eq(z.re, add(z.re, z.im)))
})