package granary
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/granary.ivm/Granary_ivm/Zset/Make/index.html
Module Zset.MakeSource
Make (E) builds a Z-set module over element domain E.
Parameters
Signature
A Z-set: a finitely-supported elt -> int weight map, kept canonical (no zero-weight entries).
is_zero z is true iff z has no elements (equivalently, total weight everywhere is 0).
of_list pairs sums the weights of repeated elements; entries that sum to 0 are dropped.
to_list z returns the (element, nonzero-weight) pairs, ordered by the element ELEMENT.compare.
add a b is the pointwise sum of weights, dropping any that cancel to 0. Commutative, associative, with identity zero.
negate z flips the sign of every weight (the additive inverse: add z (negate z) = zero).
map f z applies f to each element, summing the weights of elements that collide onto the same image (and dropping any that cancel). A linear operator: map f (add a b) = add (map f a) (map f b).
filter p z keeps the entries whose element satisfies p, weights unchanged. A linear operator.
distinct z is the set-semantics projection: every element with weight > 0 is mapped to weight 1; elements with weight <= 0 are dropped. Idempotent.
support z is the list of elements with nonzero weight, ordered by ELEMENT.compare.
cardinality z is the number of distinct elements with nonzero weight.
iter f z applies f element weight to each entry, in element order.
fold f z acc folds f element weight over the entries, in element order.
Structural equality (canonical form makes this exact set/weight equality).
Pretty-print a Z-set as {e1: w1, e2: w2, …}.