9 lines
283 B
JavaScript
9 lines
283 B
JavaScript
import {numComplex} from './Complex.mjs'
|
|
export const negate = {
|
|
Complex: [['self'], ref => z => {
|
|
/* need a "base case" to avoid infinite self-reference */
|
|
if (numComplex(z)) return {re: -z.re, im: -z.im}
|
|
return {re: ref.self(z.re), im: ref.self(z.im)}
|
|
}]
|
|
}
|