Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

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

NameTypeDescription
nodeMathNode

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"));
2d6

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.