feat(poortf): add concept of 'author' to an imp of a TF

And make it so that if the same author adds imps again, they replace
  the previous imps from that author.

  Use this feature to avoid the explicit check for double-inclusion in
  subtract, and test it worked.
This commit is contained in:
Glen Whitney 2022-03-25 11:31:06 -07:00
parent 2c1b6c3364
commit 00a7f79552
4 changed files with 34 additions and 13 deletions

View file

@ -1,9 +1,9 @@
export default function create(pmath) {
const add = pmath('add')
const negate = pmath('negate')
if (!pmath.subtract) { // avoid double definition at cost of extensibility
pmath('subtract', [args => args.length === 2,
(x, y) => add(x, negate(y))])
}
return pmath(
'subtract',
[args => args.length === 2, (x, y) => add(x, negate(y))],
create)
return pmath.subtract
}