feat: Allow self-reference in implementations
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".
This commit is contained in:
parent
77b04fbdbb
commit
66cbccfbbe
13 changed files with 99 additions and 21 deletions
3
bigint/BigInt.mjs
Normal file
3
bigint/BigInt.mjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
import typed from 'typed-function'
|
||||
|
||||
typed.addType({name: 'bigint', test: b => typeof b === 'bigint'})
|
4
bigint/add.mjs
Normal file
4
bigint/add.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
import './BigInt.mjs'
|
||||
export const add = {
|
||||
'...bigint': [[], addends => addends.reduce((x,y) => x+y, 0n)],
|
||||
}
|
3
bigint/all.mjs
Normal file
3
bigint/all.mjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
export {add} from './add.mjs'
|
||||
export {negate} from './negate.mjs'
|
||||
export {subtract} from '../generic/subtract.mjs'
|
2
bigint/negate.mjs
Normal file
2
bigint/negate.mjs
Normal file
|
@ -0,0 +1,2 @@
|
|||
import './BigInt.mjs'
|
||||
export const negate = {bigint: [[], b => -b ]}
|
Loading…
Add table
Add a link
Reference in a new issue