Glen Whitney
1c1ba91e48
The interface is a bit clunky, the "author" and the callback "data" have to be specified when adding (an) implementation(s) in order for this to work. But it does, and this is just a PoC, the interface could be cleaned up.
10 lines
249 B
JavaScript
10 lines
249 B
JavaScript
export default function create(pmath) {
|
|
const add = pmath('add')
|
|
const negate = pmath('negate')
|
|
return pmath(
|
|
'subtract',
|
|
[args => args.length === 2, (x, y) => add(x, negate(y))],
|
|
create, pmath)
|
|
return pmath.subtract
|
|
}
|