Learn R Programming

itertools2 (version 0.1.1)

icount: Iterator of neverending numeric sequence with initial value and step size

Description

Constructs an iterator that generates a neverending sequence of evenly spaced values starting with icount. The step size is given by step.

Usage

icount(start = 0, step = 1)

Arguments

start
sequence's initial value
step
sequence's step size

Value

sequence's iterator

Details

NOTE: Use a negative step size to generate decreasing sequences.

Often used as an argument to imap to generate consecutive data points.

Examples

Run this code
it <- icount()
iterators::nextElem(it)
iterators::nextElem(it)
iterators::nextElem(it)

it2 <- icount(start=5.5, step=1.5)
iterators::nextElem(it2)
iterators::nextElem(it2)
iterators::nextElem(it2)

Run the code above in your browser using DataLab