View source: R/30-api-flexseq-get-measure.R
| get_measures | R Documentation |
Applies the named monoid's measure() function to each leaf entry in
sequence order, returning the results as a new flexseq.
get_measures(x, monoid_name)
x |
A flexseq (or any immutables subclass). |
monoid_name |
Name of an attached monoid. |
Each leaf in a finger tree stores a structure-specific entry
(flexseq: the raw element; ordered_sequence: list(value, key);
priority_queue: list(value, priority); interval_index:
list(value, start, end)). A monoid's measure() function is defined
over that entry shape, and this accessor exposes the per-element
values that would be combined to produce the cached aggregate.
Returns a flexseq rather than a base list so results can be piped
back into other immutables operations; use as.list() or unlist()
to convert.
A plain unnamed flexseq of length length(x). Entry i is
the monoid's measure() applied to the i-th leaf entry.
get_measure(), measure_monoid(), fapply()
sum_m <- measure_monoid(`+`, 0, function(el) el)
x <- add_monoids(as_flexseq(c(3, 1, 4, 1, 5, 9)), list(sum = sum_m))
get_measures(x, "sum") |> unlist()
q <- priority_queue("a", "b", "c", priorities = c(5, 1, 3))
# Per-element .pq_min measures — each is list(has, priority).
get_measures(q, ".pq_min")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.