feat: Start arithmetic functions for complex
All checks were successful
/ test (pull_request) Successful in 17s
All checks were successful
/ test (pull_request) Successful in 17s
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
This commit is contained in:
parent
0ff00ff8cb
commit
474cc53d68
9 changed files with 95 additions and 7 deletions
|
@ -5,6 +5,14 @@ import * as numbers from './number/all.js'
|
|||
import * as complex from './complex/all.js'
|
||||
import {TypeDispatcher} from '#core/TypeDispatcher.js'
|
||||
|
||||
const math = new TypeDispatcher(booleans, coretypes, generics, numbers, complex)
|
||||
// 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue