Skip to content

Add combinatorics functions and base-suffixed logs to the math expression parser, and rework its constants - #4559

Merged
Keavon merged 2 commits into
masterfrom
math-parser-gaps
Sep 21, 2026
Merged

Keavon merged 2 commits into
masterfrom
math-parser-gaps

Conversation

@Keavon

@Keavon Keavon commented Sep 21, 2026 •

Copy link
Copy Markdown
Member
  • Adds the unary plus operator and the Unicode typeset operator aliased spellings −, ×, ⋅, ÷, ∧, ∨, and ¬.
  • Adds the choose and pick combinatorics functions, plus base-suffixed logN/rootN names with optional underscores and fractional bases like log3.25.
  • Reworks the constants: true and false join the set, infinity spells out alongside inf and ∞, and each constant now matches its lowercase spelling exactly, which keeps uppercase-initial names reserved for matrices. Removes the unitless G.
  • Retires the √ prefix operator, which is untypeable and duplicates sqrt().
  • Adds Value accessors that read a result as f32 or as any standard integer type, rounded to the nearest whole number, so host nodes stop hand-rolling those conversions.

Partly closes #2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 16 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread libraries/math-parser/src/constants.rs Outdated
Comment thread libraries/math-parser/src/lexer.rs
Comment thread libraries/math-parser/src/constants.rs
Comment thread libraries/math-parser/src/constants.rs Outdated
Comment thread node-graph/nodes/math/src/lib.rs
Comment thread editor/src/messages/portfolio/portfolio_message_handler.rs Outdated
Comment thread libraries/math-parser/src/value.rs
Comment thread libraries/math-parser/src/value.rs
Adds the unary plus operator, the `true` and `false` constants, the
`choose` and `pick` combinatorics functions, base-suffixed `logN`/
`rootN` function names with optional underscores and fractional bases
like `log3.25`, the typeset operator spellings (`−`, `×`, `⋅`, `÷`,
`∧`, `∨`, `¬`), and `Value` accessors reading results as `f32` and the
standard integer types. Constants match their lowercase spelling
exactly, since uppercase-initial names are reserved for matrices. The
`¬` spelling is the prefix logical not alone, never the postfix
factorial that `!` also spells, and punctuation never begins a name,
which leaves `#`, `$`, `~`, and `@` free to become namespace prefixes
once a host scope needs them.

Retires the `√` prefix operator, which is untypeable and duplicates
`sqrt()`, and removes the undocumented unitless `G` constant: its
9.80665 is the value of lowercase-g standard gravity under capital-G's
name, and gravity's proper home is the future unit system's `g`
acceleration unit.

Also covers the previously untested interaction between implicit
multiplication and unary minus with parenthesized operands (`2 (-3)`,
`-3(2)`) in the test suite.
@Keavon
Keavon merged commit e49c707 into master Sep 21, 2026
11 checks passed
@Keavon
Keavon deleted the math-parser-gaps branch September 21, 2026 04:32

This branch was successfully deployed

1 active deployment
graphite-dev (Preview) — 080c998e Deployed Sep 21, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking Issue: Math expression parser/calculator

1 participant