pocomath/complex/add.mjs
Glen Whitney b82336e590 feat: Add complex numbers
No negation (and therefore no subtraction) since that needs self-reference.
2022-07-19 09:52:16 -07:00

13 lines
239 B
JavaScript

import './Complex.mjs'
export const add = {
'...Complex': [[], addends => {
const sum = {re: 0, im: 0}
addends.forEach(addend => {
sum.re += addend.re
sum.im += addend.im
})
return sum
}]
}