feat: Template operations (#41)
Relational functions are added using templates, and existing generic functions are made more strict with them. Also a new built-in typeOf function is added, that automatically updates itself. Resolves #34. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #41
This commit is contained in:
parent
2609310b8e
commit
fe54bc6004
29 changed files with 480 additions and 119 deletions
|
@ -1,5 +1,3 @@
|
|||
export * from './Types/bigint.mjs'
|
||||
|
||||
export const add = {
|
||||
'...bigint': () => addends => addends.reduce((x,y) => x+y, 0n)
|
||||
}
|
||||
export const add = {'bigint,bigint': () => (a,b) => a+b}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import PocomathInstance from '../core/PocomathInstance.mjs'
|
||||
import * as bigints from './native.mjs'
|
||||
import * as generic from '../generic/arithmetic.mjs'
|
||||
import * as generic from '../generic/all.mjs'
|
||||
|
||||
export default PocomathInstance.merge('bigint', bigints, generic)
|
||||
|
|
5
src/bigint/compare.mjs
Normal file
5
src/bigint/compare.mjs
Normal file
|
@ -0,0 +1,5 @@
|
|||
export * from './Types/bigint.mjs'
|
||||
|
||||
export const compare = {
|
||||
'bigint,bigint': () => (a,b) => a === b ? 0n : (a > b ? 1n : -1n)
|
||||
}
|
|
@ -3,6 +3,7 @@ import gcdType from '../generic/gcdType.mjs'
|
|||
export * from './Types/bigint.mjs'
|
||||
|
||||
export {add} from './add.mjs'
|
||||
export {compare} from './compare.mjs'
|
||||
export {divide} from './divide.mjs'
|
||||
export const gcd = gcdType('bigint')
|
||||
export {isZero} from './isZero.mjs'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue