Skip to contents

Counts every node in the tree — both leaves (literals and variables) and interior eml nodes. This matches Odrzywolek (2026), Table 4 and Eq. 5: for log(x) = eml(1, eml(eml(1, x), 1)), eml_K returns 7.

Usage

eml_K(expr)

Arguments

expr

an EML expression.

Value

Integer scalar.

Details

This is a behaviour change from v1, which returned the leaf count (4 for the same expression). v1 semantics are still available via eml_leafcount(). See ADR-001-K-counting.md in the spec bundle.

See also

eml_leafcount() for v1's leaf-only count.

Other eml_inspectors: eml_depth(), eml_leafcount(), eml_rpn()

Examples

eml_K(quote(eml(1, 1))) # 3 (e)
#> [1] 3
eml_K(quote(eml(x, 1))) # 3 (exp)
#> [1] 3
eml_K(quote(eml(1, eml(eml(1, x), 1)))) # 7 (log, paper Eq. 5)
#> [1] 7