feat(gcd,lcm): Allow arbitrarily many arguments

And add an 'associate' predicate for two complex numbers to check the results
This commit is contained in:
Glen Whitney 2022-08-02 10:32:06 -07:00
parent 1b8314c0cc
commit 880efac15b
5 changed files with 31 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import {reducingOperation} from './reducingOperation.mjs'
export * from './Types/generic.mjs'
export const add = reducingOperation
export const gcd = reducingOperation
export {lcm} from './lcm.mjs'
export {mean} from './mean.mjs'
export {mod} from './mod.mjs'

View file

@ -1,3 +1,5 @@
import {reducingOperation} from './reducingOperation.mjs'
export const lcm = {
'T,T': ({
'multiply(T,T)': multT,
@ -5,3 +7,4 @@ export const lcm = {
'gcd(T,T)': gcdT
}) => (a,b) => multT(quotT(a, gcdT(a,b)), b)
}
Object.assign(lcm, reducingOperation)