itabulate: Iterator that maps a function to a sequence of numeric values

Description Usage Arguments Value Examples

Description

Constructs an iterator that maps a given function over an indefinite sequence of numeric values. The input the function f is expected to accept a single numeric argument. The sequence of arguments passed to f begin with start and are incremented by step.

Usage

1
itabulate(f, start = 1, step = 1)

Arguments

f

the function to apply

start

sequence's initial value

step

sequence's step size

Value

an iterator that returns the mapped values from the sequence

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
it <- itabulate(f=function(x) x + 1)
take(it, 4) # 2 3 4 5

it2 <- itabulate(f=function(x) x^2, start=-3)
take(it2, 6) # 9 4 1 0 1 4

it3 <- itabulate(abs, start=-5, step=2)
take(it3, 6) # 5 3 1 1 3 5

it4 <- itabulate(exp, start=6, step=-2)
take(it4, 4) # exp(c(6, 4, 2, 0))

itertools2 documentation built on May 2, 2019, 3:37 p.m.