for.each: Zipped function application

Description Usage Arguments Details Value See Also Examples

View source: R/functional.R

Description

for.each takes a function and a set of sequences (vectors, lists or pairlists), and applies the function successively to each set of elements that are in the sequences at the same positional index.

Usage

1

Arguments

f

A function to apply.

...

Vectors, lists or pairlists.

Details

This function combines link{zip} and link{do.call}, to apply a provided function successively to the elements of several sequences. The arity of the function must be compatible with the number of sequences passed as arguments; if not, an error will result.

As in zip, if not all sequences are the same length, shorter sequences will be recycled to match the lengths of longer ones.

Value

The value of f on the last set of parameters supplied to it, or NULL if no or only zero-length sequences were supplied as arguments.

See Also

link{zip} for the operation of zipping the parameter sequences.

Examples

1
2
f <- function(...) print(as.numeric(list(...)))
invisible(for.each(f, 1:5, 6:10, 11:15))

wwbrannon/schemeR documentation built on May 4, 2019, 12:03 p.m.