# `gno.land/p/moul/x/daily/markov/v0`
**Deterministic Markov-chain text generator** — a port of Go's canonical example
[*"Generating arbitrary text: a Markov chain algorithm"*](https://go.dev/doc/codewalk/markov/)
with `math/rand` replaced by a caller-supplied seed.
A `Chain` maps every two-word *prefix* to the list of words observed to follow
it (duplicates kept, so frequency biases the walk), storing that map in a
persistent `avl.Tree`. `Build` folds text into the chain; `Generate` walks it
from the start prefix, picking one suffix per step from a small LCG seeded by
the `uint64` you pass — so generation is pure and replayable, and the caller
decides where entropy comes from (on-chain, the block height). No chain imports,
no ambient state.
```go
import "gno.land/p/moul/x/daily/markov/v0"
c := markov.New()
c.Build("it was the best of times it was the worst of times") // fold in a corpus
words := c.Generate(40, seed) // walk it, seeded
c.Stats() // (totalWords, prefixCount)
c.Iterate(func(prefix string, suffixes []string) bool { ... }) // inspect the map
```
**Live demo:** [`r/moul/x/daily/markovdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/markovdemo/v0)
· render it at [`/r/moul/x/daily/markovdemo/v0`](https://gno.land/r/moul/x/daily/markovdemo/v0).
<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->
---
Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
**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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).
<!-- END GNOCONTRACTS FOOTER -->
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.