Adds all of the pocomath functions on Complex that do not depend on any unimplemented types or config properties, except quotient and roundquotient, where the design is murky. To get this working, 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) * Adds check for recursive loops in resolve (a key/signature depending on itself) Reviewed-on: #24 Co-authored-by: Glen Whitney <glen@studioinfinity.org> Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
parent
0ff00ff8cb
commit
aad62df8ac
33 changed files with 428 additions and 106 deletions
|
@ -1,8 +1,10 @@
|
|||
import {ReturnsAs} from './helpers.js'
|
||||
import {ResolutionError, match} from '#core/helpers.js'
|
||||
import {Returns} from '#core/Type.js'
|
||||
import {Passthru} from "#core/TypePatterns.js"
|
||||
import {ResolutionError} from '#core/helpers.js'
|
||||
import {Passthru, match} from '#core/TypePatterns.js'
|
||||
import {boolnum} from '#number/helpers.js'
|
||||
|
||||
// Most types are real. Have to make sure to redefine on all non-real types
|
||||
export const isReal = match(Passthru, boolnum(() => true))
|
||||
export const isZero = match(Passthru, (math, [T]) => {
|
||||
if (!T) { // called with no arguments
|
||||
throw new ResolutionError('isZero() requires one argument')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue