Skip to contents

A hash of a tree's structure – node kinds, child structure, leaf positions, and names – consistent with tree_equal(): trees that are tree_equal() hash to the same value. Intended as a cache key for tree-structured dispatch.

Usage

tree_hash(tree)

Arguments

tree

(RTree)
A tree as returned by build_tree().

Value

character(1), the structural hash.

Examples

tree_hash(build_tree(list(a = 1))) == tree_hash(build_tree(list(a = 2)))
#> [1] TRUE
tree_hash(build_tree(list(a = 1))) == tree_hash(build_tree(list(b = 1)))
#> [1] FALSE