nanomath/src/complex/utils.js
Glen Whitney f9b723b882
All checks were successful
/ test (pull_request) Successful in 17s
feat: Add isReal and isZero, and fix specializing a generic type
2025-04-25 00:08:29 -07:00

9 lines
363 B
JavaScript

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)))
})