Skip to contents

Recursively extract elements by name from a nested structure

Usage

extract_ast_elements(obj, name, recursive = TRUE)

Arguments

obj

A nested list or S3 object (e.g., multimod or ast node)

name

Character string of the slot/element to extract (e.g., "when")

recursive

Logical, whether to search recursively through nested objects

Value

A list of all matching elements

Examples

eq <- example_models$energyRt$multimod$equations[[1]]
length(extract_ast_elements(eq, "when"))
#> [1] 0