Transaction

D6E9164691160C…166EBF2ED56B

Block 26,113 · index 0 · indexed

Summary

Hash
D6E9164691160CA293FC12B00C1CB837EE3960A9337EFC5CA96E166EBF2ED56B
Block
26,113
Size
4936 bytes
Gas used
9,917,752 / 11,901,362
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

Arguments · 9

  1. #1sievedemo
  2. #2README.md
  3. #3# `gno.land/r/moul/x/daily/sievedemo/v0` Interactive gnoweb **demo of the [`p/moul/x/daily/sieve`](https://github.com/moul/gno-contracts/tree/main/p/moul/x/daily/sieve/v0) Sieve of Eratosthenes library** — it renders the count of primes up to `MaxN`, the first 100 primes, and a "primes up to n" grid. It has no sieve logic of its own. Append a number to the path to sieve up to any n (max 10000), e.g. [`/r/moul/x/daily/sievedemo/v0:1000`](https://gno.land/r/moul/x/daily/sievedemo/v0:1000). <!-- 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:** ![gno.land/r/moul/x/daily/sievedemo/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/r/moul/x/daily/sievedemo/v0/deps.png) > 🧪 **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 -->
  4. #4gnomod.toml
  5. #5module = "gno.land/r/moul/x/daily/sievedemo/v0" gno = "0.9"
  6. #6sievedemo.gno
  7. #7// Package sievedemo is a small gnoweb demo of the Sieve of Eratosthenes // provided by the [p/moul/x/daily/sieve](/p/moul/x/daily/sieve/v0) library: it // renders the primes up to MaxN, the first 100 primes, and an interactive // "primes up to n" grid. // // It contains no sieve logic of its own — everything comes from // `sieve.PrimesUpTo` and `sieve.MaxN`. package sievedemo import ( "strconv" "strings" "gno.land/p/moul/x/daily/sieve/v0" ) // Render renders the sieve for gnoweb. // // Render("") / Render("/") -> first 100 primes + total count up to MaxN // Render("/<n>") -> every prime <= n, laid out as a grid func Render(path string) string { n, hasN := parseN(path) var b strings.Builder b.WriteString("# Sieve of Eratosthenes\n\n") b.WriteString("A deterministic on-chain port of Go's classic concurrent prime-sieve example, ") b.WriteString("demoing the [`p/moul/x/daily/sieve`](/p/moul/x/daily/sieve/v0) library.\n\n") if !hasN { primes := sieve.PrimesUpTo(sieve.MaxN) b.WriteString("There are **") b.WriteString(strconv.Itoa(len(primes))) b.WriteString("** primes up to ") b.WriteString(strconv.Itoa(sieve.MaxN)) b.WriteString(".\n\n") b.WriteString("## First 100 primes\n\n") first := primes if len(first) > 100 { first = first[:100] } b.WriteString(grid(first, 10)) b.WriteString("\n> Try `/500` or `/1000` to sieve up to any n (max ") b.WriteString(strconv.Itoa(sieve.MaxN)) b.WriteString(").\n") return b.String() } if n < 2 { b.WriteString("No primes <= ") b.WriteString(strconv.Itoa(n)) b.WriteString(".\n") return b.String() } clamped := n if clamped > sieve.MaxN { clamped = sieve.MaxN } primes := sieve.PrimesUpTo(clamped) b.WriteString("## Primes up to ") b.WriteString(strconv.Itoa(clamped)) if clamped != n { b.WriteString(" (clamped from ") b.WriteString(strconv.Itoa(n)) b.WriteString(")") } b.WriteString("\n\n") b.WriteString("Count: **") b.WriteString(strconv.Itoa(len(primes))) b.WriteString("**\n\n") b.WriteString(grid(primes, 10)) return b.String() } // parseN extracts n from a Render path like "/1000". Returns hasN=false for // the empty/root path. func parseN(path string) (int, bool) { s := strings.TrimSpace(path) s = strings.TrimPrefix(s, "/") if s == "" { return 0, false } // keep only the first segment if i := strings.IndexByte(s, '/'); i >= 0 { s = s[:i] } v, err := strconv.Atoi(s) if err != nil { return 0, false } return v, true } // grid formats primes into a Markdown table with `cols` columns per row. func grid(primes []int, cols int) string { if len(primes) == 0 { return "_none_\n" } if cols < 1 { cols = 1 } var b strings.Builder // header + separator so gnoweb renders it as a table b.WriteString("|") for c := 0; c < cols; c++ { b.WriteString(" · |") } b.WriteString("\n|") for c := 0; c < cols; c++ { b.WriteString("---|") } b.WriteString("\n") for i := 0; i < len(primes); i += cols { b.WriteString("|") for c := 0; c < cols; c++ { b.WriteString(" ") if i+c < len(primes) { b.WriteString(strconv.Itoa(primes[i+c])) } b.WriteString(" |") } b.WriteString("\n") } return b.String() }
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

msg:0,success:true,log:,events:[]

← Back to block 26,113