2022-12-07 01:21:05 +00:00
|
|
|
import {Dispatcher} from './core/Dispatcher.js'
|
|
|
|
import * as Specifications from './all.js'
|
2022-12-06 17:10:18 +00:00
|
|
|
|
|
|
|
export default new Dispatcher(Specifications)
|
2023-01-22 01:34:57 +00:00
|
|
|
|
|
|
|
import {Complex} from './Complex/type.js'
|
|
|
|
import {absquare as absquare_complex} from './Complex/arithmetic.js'
|
|
|
|
|
|
|
|
const mockRealAdd = (a: number, b: number) => a+b
|
|
|
|
const mockComplexAbsquare = (z: Complex<number>) => z.re*z.re + z.im*z.im
|
|
|
|
|
|
|
|
const quatAbsquare = absquare_complex({
|
|
|
|
add: mockRealAdd,
|
|
|
|
absquare: mockComplexAbsquare
|
|
|
|
})
|
|
|
|
|
|
|
|
const myabs = quatAbsquare({re: {re: 0, im: 1}, im: {re:2, im: 3}})
|
|
|
|
const typeTest: typeof myabs = 7 // check myabs is just a number
|
|
|
|
|
|
|
|
console.log('Result is', myabs)
|
2023-08-18 17:57:30 +00:00
|
|
|
|
|
|
|
// Check type of the generic square implementation
|
|
|
|
console.log('Type of square is', Specifications.generic.square.reflectedType)
|