You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
912 B
34 lines
912 B
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), [])
|
|
}
|
|
}
|