Learn R Programming

rlang (version 0.1.6)

lang_head: Return the head or tail of a call object

Description

These functions return the head or the tail of a call. See section on calls as parse trees in lang(). They are equivalent to node_car() and node_cdr() but support quosures and check that the input is indeed a call before retrieving the head or tail (it is unsafe to do this without type checking).

lang_head() returns the head of the call without any conversion, unlike lang_name() which checks that the head is a symbol and converts it to a string. lang_tail() returns the pairlist of arguments (while lang_args() returns the same object converted to a regular list)

Usage

lang_head(lang)

lang_tail(lang)

Arguments

lang

Can be a call (language object), a formula quoting a call in the right-hand side, or a frame object from which to extract the call expression.

See Also

pairlist, lang_args(), lang()

Examples

Run this code
# NOT RUN {
lang <- quote(foo(bar, baz))
lang_head(lang)
lang_tail(lang)
# }

Run the code above in your browser using DataLab