Start MathPage class

ui
Garrett Mills 2 years ago
parent 189439227f
commit 8f42f771d8

@ -0,0 +1,33 @@
import {MathStatement} from './parse'
import * as math from 'mathjs'
export class MathPage {
protected statements: Record<string, MathStatement> = {}
constructor(
public readonly id: string,
) {}
addStatement(statement: MathStatement): this {
this.statements[statement.id] = statement
return this
}
symbols(): math.SymbolNode[] {
return Object.values(this.statements)
.map(x => x.symbols())
.reduce((carry, current) => current.concat(carry), [])
}
defines(): math.SymbolNode[] {
return Object.values(this.statements)
.map(x => x.defines())
.reduce((carry, current) => current.concat(carry), [])
}
uses(): math.SymbolNode[] {
return Object.values(this.statements)
.map(x => x.uses())
.reduce((carry, current) => current.concat(carry), [])
}
}

@ -253,6 +253,7 @@ export class LValSymbolWalk extends SymbolWalk {
export class MathStatement {
constructor(
public readonly id: string,
public readonly raw: string,
) {}

Loading…
Cancel
Save