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 fenwickdemo is a small gnoweb demo of the Binary Indexed Tree provided by the [p/moul/x/daily/fenwick](/p/mou...

Readme View source

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

A gnoweb demo of the p/moul/x/daily/fenwick library: prefix sums, range queries, the internal ranges that make a Binary Indexed Tree legible, and the weighted draw that is the reason to use one.

It holds no tree logic of its own and no state. Every figure on the page is computed from two fixed tables in the source, never from chain state, which is what lets ExampleRender pin the whole page: the pinned block is copied from what gno printed, so a change in the library shows up as a diff in the test rather than as prose nobody re-reads.

The page is in five parts, and the last two are the ones worth reading:

  • What the tree actually stores. The array is not a copy of the values; each node holds the sum of a run of them, and the run lengths are the powers of two in the index. Covers turns that from a claim into a table.
  • The weighted draw. Five holders, one of them with a zero stake, and the exact range of targets each one owns. Target 30 is the interesting row: it is the first past the first holder's share and it skips the zero-stake holder entirely, because a zero does not advance the prefix.

Rendering is deterministic and costs no chain reads, so the page is the same on every node and at every height.


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/fenwickdemo/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 fenwickdemo is a small gnoweb demo of the Binary Indexed Tree provided by the p/moul/x/daily/fenwick(/p/moul/x/daily/fenwick/v0) library: prefix sums, range queries, the internal ranges that make the structure legible, and the weighted draw that is the reason to use one.

It contains no tree logic of its own. Stateless, so Render is deterministic: every figure below is computed from the fixed tables at the top of this file, never from chain state, which is what lets an example test pin the page.

Functions 1

func Render

1func Render(path string) string
source

Render renders the demo for gnoweb.

Example
1Render("") / Render("/") -> the full demo

Imports 4

Source Files 4