Glen Whitney
66cbccfbbe
And use it to define negate and add for Complex numbers in a way that is independent of component types. Also add a bigint type and verify that pocomath will then handle Gaussian integers "for free".
12 lines
348 B
JavaScript
12 lines
348 B
JavaScript
import './Complex.mjs'
|
|
|
|
export const complex = {
|
|
/* Very permissive for sake of proof-of-concept; would be better to
|
|
* have a numeric/scalar type, e.g. by implementing subtypes in
|
|
* typed-function
|
|
*/
|
|
'any, any': [[], (x, y) => ({re: x, im: y})],
|
|
/* Take advantage of conversions in typed-function */
|
|
Complex: [[], z => z]
|
|
}
|