nanomath/src/nanomath.js
Glen Whitney 474cc53d68
All checks were successful
/ test (pull_request) Successful in 17s
feat: Start arithmetic functions for complex
So far, adds absquare and add. To get these working, especially on mixed
  types of arguments, this also adds some additional features:
  * Allows conversions to generic types, with the matched type
    determined from the return value of the built convertor
  * Adds predicate-based type patterns
  * Adds conversion from any non-complex type T to Complex(T)
  * Starts tests for complex arithmetic
2025-04-24 12:06:47 -07:00

18 lines
900 B
JavaScript

import * as booleans from './boolean/all.js'
import * as coretypes from './coretypes/all.js'
import * as generics from './generic/all.js'
import * as numbers from './number/all.js'
import * as complex from './complex/all.js'
import {TypeDispatcher} from '#core/TypeDispatcher.js'
// At the moment, since we are not sorting patterns in any way,
// order matters in the construction. Patterns that come later in
// the following list will be tried earlier. (The rationale for that
// ordering is that any time you merge something, it should supersede
// whatever has been merged before.)
// Hence, in building the math instance, we put complex first because
// we want its conversion (which converts _any_ non-complex type to
// complex, potentially making a poor overload choice) to be tried last.
const math = new TypeDispatcher(complex, generics, booleans, coretypes, numbers)
export default math