elementwise: Apply a function to each element of an lvec

Description Usage Arguments Value Examples

Description

Apply a function to each element of an lvec

Usage

1
elementwise(x, fun, ...)

Arguments

x

an object of type lvec.

fun

the function to apply to the lvec. This function receives chunks of the lvec (which are regular R-vector) and should return a (R) vector of the same length as its input.

...

passed on to fun.

Value

Returns a link{lvec} of the same length as the input. The type is determined by the output of fun.

Examples

1
2
3
4
5
# Calculate square root of lvec
x <- as_lvec(1:10)
y <- elementwise(x, sqrt)
# of course, this is already implemented
sqrt(x)

ldat documentation built on May 2, 2019, 4:22 a.m.