Glen Whitney
c429c19dfe
This should eventually be moved into typed-function itself, but for now it can be implemented on top of the existing typed-function. Uses subtypes to define (and error-check) gcd and lcm, which are only defined for integer arguments. Resolves #36.
15 lines
309 B
JavaScript
15 lines
309 B
JavaScript
export * from './Types/Complex.mjs'
|
|
|
|
export const multiply = {
|
|
'Complex,Complex': ({
|
|
'complex(any,any)': cplx,
|
|
add,
|
|
subtract,
|
|
self
|
|
}) => (w,z) => {
|
|
return cplx(
|
|
subtract(self(w.re, z.re), self(w.im, z.im)),
|
|
add(self(w.re, z.im), self(w.im, z.re)))
|
|
}
|
|
}
|