Skip to contents

Walks two trees in parallel and returns the first path/subtree pair where they diverge, or NULL if they are structurally identical. The returned prefix follows tree_path() syntax; a and b are the tree_repr() strings of the diverging subtrees.

Usage

tree_diff(a, b)

Arguments

a, b

(RTree)
Trees to compare, as returned by build_tree().

Value

NULL if a and b are structurally identical, otherwise a list with elements prefix, a, and b.

Examples

tree_diff(build_tree(list(a = 1)), build_tree(list(a = list(1, 2))))
#> $prefix
#> [1] "a"
#> 
#> $a
#> [1] "*"
#> 
#> $b
#> [1] "list(*, *)"
#>