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

Package markovdemo is a small on-chain demo of the Markov-chain text generator provided by the [p/moul/x/daily/markov...

Readme View source

gno.land/r/moul/x/daily/markovdemo/v0

Live demo of the p/moul/x/daily/markov Markov-chain text generator.

Holds one package-level markov.Chain as the on-chain corpus and wires it to the chain — babbling is seeded by runtime.ChainHeight(), so Generate stays a pure, reproducible query that still varies block to block. The realm ships pre-seeded with a couple of sentences, so a fresh deploy already babbles:

  • Feed(cur, text) — tokenize text and fold it into the corpus (the crossing function; any caller may enrich it).
  • Generate(nWords) string — babble ~nWords words, seeded by the block height.
  • Stats() (int, int) — returns (totalWords, prefixCount).
  • Render("/60") — a fresh 60-word sample plus corpus stats and a sample of prefix → suffix rows; Render("") defaults to 40 words.

All build/walk math lives in the library; this realm is just the wiring and the gnoweb view. Render it at /r/moul/x/daily/markovdemo/v0.


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

Dependency graph:

gno.land/r/moul/x/daily/markovdemo/v0 dependency graph

🧪 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 markovdemo is a small on-chain demo of the Markov-chain text generator provided by the p/moul/x/daily/markov(/p/moul/x/daily/markov/v0) library.

It holds a single package-level markov.Chain as the corpus and wires it to the chain: Feed appends words to that persistent chain (a crossing function, since it mutates on-chain state), while Generate and Render walk it with a seed derived from runtime.ChainHeight() — so babbling is a pure, reproducible query that still varies block to block. It contains no Markov logic of its own — build/walk math all lives in the library.

Functions 4

func Feed

crossing Action
1func Feed(cur realm, text string) string
source

Feed appends text to the on-chain corpus, extending the Markov chain. Any caller may enrich the corpus — this is the open-membership demo model.

func Generate

Action
1func Generate(nWords int) string
source

Generate babbles up to nWords of Markov text from the current corpus, seeded deterministically by the chain height. Read-only.

func Render

1func Render(path string) string
source

Render shows a freshly generated sample plus corpus stats. The path may carry a word count, e.g. Render("/60").

func Stats

Action
1func Stats() (int, int)
source

Stats returns (totalWords, prefixCount) for the current corpus.

Imports 5

Source Files 3