The vecvec_apply_fn() function is a function factory that creates applies the function .f to each vector and optionally simplifies the result with [unvecvec()]. The function matches the forms of the original function .f and can be used to define methods for generic functions that apply to vecvec objects. If .f is a primitive function, the resulting function will have a apply over an argument x and pass through ....

vecvec_apply_fn(.f, ptype = NULL, SIMPLIFY = !is.null(ptype))

Arguments

.f

A function to apply to each vector

ptype

A prototype to simplify to. If NULL, the result will be a vecvec object. If not NULL, the result will be simplified to the type of ptype if possible.

SIMPLIFY

If TRUE, the [unvecvec()] will be applied to the result of vecvec_apply(), using ptype as the target type. If FALSE, the result will always be a vecvec object.

Value

A function that applies .f to each vector of a vecvec object and optionally simplifies the result.