rgp (version 0.4-1)

iterate: Repeatedly apply a function

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

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.