feat: Add and illustrate multiple ways of specifying implementations #19

Merged
glen merged 3 commits from pocomath_notation into main 2022-07-23 05:06:49 +00:00
3 changed files with 8 additions and 2 deletions
Showing only changes of commit 2ef0b5b263 - Show all commits

View File

@ -1,5 +1,6 @@
import {use} from '../core/PocomathInstance.mjs'
export {Types} from './Types/bigint.mjs'
export const add = {
'...bigint': [[], addends => addends.reduce((x,y) => x+y, 0n)],
'...bigint': use([], addends => addends.reduce((x,y) => x+y, 0n))
}

View File

@ -1,3 +1,4 @@
import {use} from '../core/PocomathInstance.mjs'
export {Types} from './Types/bigint.mjs'
export const negate = {bigint: [[], b => -b ]}
export const negate = {bigint: use([], b => -b)}

View File

@ -1,6 +1,10 @@
/* Core of pocomath: create an instance */
import typed from 'typed-function'
export function use(dependencies, implementation) {
return [dependencies, implementation]
}
export default class PocomathInstance {
/* Disallowed names for ops; beware, this is slightly non-DRY
* in that if a new top-level PocomathInstance method is added, its name