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 pure

Package romannum is a pure port of the classic Roman-numeral converter kata: ToRoman / FromRoman, valid for 1..3999. ...

Readme View source

gno.land/p/moul/x/daily/romannum/v0

Roman-numeral converterToRoman, FromRoman.

A pure port of the classic kata, valid for 1..3999. ToRoman uses greedy subtractive notation (panics out of range); FromRoman accepts a numeral only if it is canonical (it must round-trip through ToRoman), so malformed forms like IIII, VV, or IC are rejected. Deterministic — no time, randomness, or I/O — and free of any realm coupling.

1import "gno.land/p/moul/x/daily/romannum/v0"
2
3s := romannum.ToRoman(2024) // "MMXXIV"
4n := romannum.FromRoman(s)   // 2024 (panics on a malformed numeral)

Live demo: r/moul/x/daily/romannumdemo · render it at /r/moul/x/daily/romannumdemo/v0.


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.

Overview

Package romannum is a pure port of the classic Roman-numeral converter kata: ToRoman / FromRoman, valid for 1..3999. Deterministic — no time, randomness or I/O — and free of any realm coupling, so it is reusable as a library.

A live demo of this package (an interactive integer↔Roman converter) is at r/moul/x/daily/romannumdemo(/r/moul/x/daily/romannumdemo/v0).

Functions 2

func FromRoman

1func FromRoman(s string) int
source

FromRoman parses a Roman numeral back to an integer. It panics on any malformed input (e.g. "IIII", "IC", "VV").

func ToRoman

1func ToRoman(n int) string
source

ToRoman renders an integer in 1..3999 as a Roman numeral. It panics if n is out of range.

Imports 2

  • strconv stdlib
  • strings stdlib

Source Files 3