pocomath/complex/negate.mjs
Glen Whitney 4999cad775 fix: prevent obsolete typed-functions from hanging around
In other words, if name a depends on b and b is invalidated (because
  of added implementations), then a must be invalidated as well.

  Also adds a specific test (custom/piecemeal) that tests this.
2022-07-19 11:48:52 -07:00

9 lines
280 B
JavaScript

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