Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Readme View source

RPN Calculator

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily


A shared, stack-based Reverse Polish Notation calculator realm. Anyone can push tokens onto a single shared stack: integers are pushed as-is, while an operator (+, -, *, /) pops the top two operands and pushes the result. Divide-by-zero and stack underflow abort the transaction, and Clear resets the stack. Render shows the current stack (bottom→top), the top value as the result, and a usage guide.

Realm path

gno.land/r/REPLACE_ADDR/calc

Example calls

# Compute (5 3 +) = 8
Push("5")
Push("3")
Push("+")

# Chain: (10 4 -) 2 * = 12
Push("10")
Push("4")
Push("-")
Push("2")
Push("*")

# Reset
Clear()

Read the current state via Render (e.g. the realm's rendered page).


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Variables 2

var ErrDivByZero

1var ErrDivByZero = errors.New("division by zero")
source

ErrDivByZero is raised on division by zero.

var ErrUnderflow

1var ErrUnderflow = errors.New("stack underflow: operator needs two operands")
source

ErrUnderflow is raised when an operator needs more operands than available.

Functions 5

func Depth

Action
1func Depth() int
source

Depth returns the number of values currently on the stack.

func Push

crossing Action
1func Push(cur realm, token string)
source

Push consumes a single token: an integer is pushed onto the stack; an operator (+, -, *, /) pops two operands and pushes the result.

func Render

1func Render(path string) string
source

Render renders the current stack, the top value as the result, and a short usage guide.

func Top

Action
1func Top() (int, bool)
source

Top returns the top value and whether the stack is non-empty.

Imports 4

  • chain stdlib
  • errors stdlib
  • strconv stdlib
  • strings stdlib

Source Files 3