# NOT RUN {
is_lang(quote(foo(bar)))
# You can pattern-match the call with additional arguments:
is_lang(quote(foo(bar)), "foo")
is_lang(quote(foo(bar)), "bar")
is_lang(quote(foo(bar)), quote(foo))
# Match the number of arguments with is_lang():
is_lang(quote(foo(bar)), "foo", 1)
is_lang(quote(foo(bar)), "foo", 2)
# Or more specifically:
is_unary_lang(quote(foo(bar)))
is_unary_lang(quote(+3))
is_unary_lang(quote(1 + 3))
is_binary_lang(quote(1 + 3))
# By default, namespaced calls are tested unqualified:
ns_expr <- quote(base::list())
is_lang(ns_expr, "list")
# You can also specify whether the call shouldn't be namespaced by
# supplying an empty string:
is_lang(ns_expr, "list", ns = "")
# Or if it should have a namespace:
is_lang(ns_expr, "list", ns = "utils")
is_lang(ns_expr, "list", ns = "base")
# The name argument is vectorised so you can supply a list of names
# to match with:
is_lang(quote(foo(bar)), c("bar", "baz"))
is_lang(quote(foo(bar)), c("bar", "foo"))
is_lang(quote(base::list), c("::", ":::", "$", "@"))
# }
Run the code above in your browser using DataLab