iterate: Repeatedly apply a function

Description Usage Arguments Value

View source: R/function_utils.r

Description

Repeatedly apply a function f to an argument arg, additional arguments ... are supplied unchanged in each call. E.g. iterate(3, foo, 42.14, "bar") is equivalent to foo(foo(foo(42.14, "bar"), "bar"), "bar").

Usage

1
iterate(n, f, arg, ...)

Arguments

n

The number of times to apply f, must be >= 0. If 0, arg is returned.

f

The function to apply.

arg

The argument to repeatedly apply f to.

...

Additional argument to pass to f at each application.

Value

The result of repeatedly applying f.


rgp documentation built on May 30, 2017, 12:45 a.m.