feat: Allow self-reference in implementations (#4)
This PR also uses such self-reference to define negate and add for Complex numbers in a way that is independent of component types. Also adds a bigint type and verifies that pocomath will then handle Gaussian integers "for free". Ensures that if one function is invalidated, then any that depend on it will be. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #4
This commit is contained in:
parent
77b04fbdbb
commit
84a8b9d5c4
13 changed files with 132 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