picomath/number/number.js

19 lines
393 B
JavaScript
Raw Normal View History

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)])
}