m2_evaluate
Execute Macaulay2 code in a persistent session and retrieve its output, with state preserved across calls for multi-step computations such as Groebner bases and Hilbert polynomials.
Instructions
Evaluate Macaulay2 code in the persistent session and return its output.
State (rings, variables, ideals, ...) persists across calls. M2 errors
are included in the returned text and do not break the session.
Separate statements with newlines: a trailing ";" suppresses that
statement's result (use an explicit "print" to force output).
Args:
code: Macaulay2 code, e.g. "R = QQ[x,y,z]
I = ideal(x^3 - y, x^4 - z) print generators (gb I)" timeout_s: Author-set safety limit (default 120, max 3600). Raise it for heavy computations (large Groebner bases, Hilbert polynomials, ...). On timeout the session is restarted, so the retried code must include all setup again. stop_on_error: Default False = REPL semantics (an error does not stop later lines from running). True sends the code input by input and halts at the first error, leaving later inputs unexecuted. Requires each line to be a self-contained statement (do not break a line after a binary operator).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout_s | No | ||
| stop_on_error | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |