picomath/number/number.js
Glen Whitney 32bc9ca515 feat: Add complex numbers
With just the operations we have for numbers, and overall tests.
2022-03-25 01:54:20 -07:00

19 lines
393 B
JavaScript

export function isNumber(x) {
return typeof x === 'number'
}
export function allNumbers(args) {
for (let i = 0; i < args.length; ++i) {
if (!isNumber(args[i])) return false
}
return true
}
export function oneNumber(args) {
return args.length === 1 && isNumber(args[0])
}
export default function create(pmath) {
return pmath('number', [() => true, x => Number(x)])
}