fix: Separate typed instance for each PocomathInstance (#15)
Also starts each PocomathInstance with no types at all, and uses the new situation to eliminate the need for a Complex "base case". Resolves #14. Resolves #13. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #15
This commit is contained in:
parent
ed71b15969
commit
0069597a76
25 changed files with 120 additions and 74 deletions
7
src/number/Types/number.mjs
Normal file
7
src/number/Types/number.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export const Types = {
|
||||
number: {
|
||||
test: n => typeof n === 'number',
|
||||
string: s => +s
|
||||
}
|
||||
}
|
||||
|
||||
5
src/number/add.mjs
Normal file
5
src/number/add.mjs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export {Types} from './Types/number.mjs'
|
||||
|
||||
export const add = {
|
||||
'...number': [[], addends => addends.reduce((x,y) => x+y, 0)],
|
||||
}
|
||||
4
src/number/all.mjs
Normal file
4
src/number/all.mjs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export {Types} from './Types/number.mjs'
|
||||
export {add} from './add.mjs'
|
||||
export {negate} from './negate.mjs'
|
||||
export {subtract} from '../generic/subtract.mjs'
|
||||
3
src/number/negate.mjs
Normal file
3
src/number/negate.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export { Types } from './Types/number.mjs'
|
||||
|
||||
export const negate = {number: [[], n => -n]}
|
||||
Loading…
Add table
Add a link
Reference in a new issue