Reference · Rolls and exact odds
mathTextfunction
A formula as notation writes it, with brackets only where they are needed. dice writes the kind at a place.
Import it
import { mathText } from "@johnmorrisdotca/korokoro";
Definition
function mathText(node: MathNode, dice: (group: number) => string): string
Parameters
| Name | Type | Description |
|---|---|---|
node | MathNode | The arithmetic expression tree. |
dice | (group: number) => string | Dice notation, or a callback giving notation for a formula group. |
Returns
string
A formula as notation writes it, with brackets only where they are needed. dice writes the kind at a place.
Examples
import { mathText } from "@johnmorrisdotca/korokoro";
console.log(mathText({ kind: "dice", group: 0 }, () => "2d6"));2d6What it prints (run when this page was built)