feat: Template implementations
This commit is contained in:
parent
1076c3c727
commit
fd3d6b2eb3
9 changed files with 67 additions and 23 deletions
|
@ -1,10 +1,12 @@
|
|||
export * from './Types/Complex.mjs'
|
||||
|
||||
export const add = {
|
||||
'...Complex': ({self}) => addends => {
|
||||
if (addends.length === 0) return {re:0, im:0}
|
||||
const seed = addends.shift()
|
||||
return addends.reduce(
|
||||
(w,z) => ({re: self(w.re, z.re), im: self(w.im, z.im)}), seed)
|
||||
}
|
||||
'Complex,number': ({
|
||||
'self(number,number)': addNum,
|
||||
'complex(any,any)': cplx
|
||||
}) => (z,x) => cplx(addNum(z.re, x), z.im),
|
||||
'Complex,Complex': ({
|
||||
self,
|
||||
'complex(any,any)': cplx
|
||||
}) => (w,z) => cplx(self(w.re, z.re), self(w.im, z.im))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue