9 lines
289 B
JavaScript
9 lines
289 B
JavaScript
import {numComplex} from './types/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)}
|
|
}]
|
|
}
|