irepeat: Iterator that returns an object indefinitely

Description Usage Arguments Details Value Examples

View source: R/irepeat.r

Description

Constructs an iterator that returns an object over and over again.

Usage

1
irepeat(object, times = NULL)

Arguments

object

object to return indefinitely.

times

the number of times object is returned. If NULL (default), object is returned indefinitely.

Details

Runs indefinitely unless the times argument is specified. Used as argument to imap for invariant function parameters. Also used with izip to create constant fields in a tuple record.

Value

iterator that returns object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
it <- irepeat(42)
iterators::nextElem(it)
iterators::nextElem(it)
iterators::nextElem(it)
# Further calls to iterators::nextElem(it) will repeat 42

it2 <- irepeat(42, times=4)
iterators::nextElem(it2)
iterators::nextElem(it2)
iterators::nextElem(it2)
iterators::nextElem(it2)

# The object can be a data.frame, matrix, etc
it3 <- irepeat(iris, times=4)
iterators::nextElem(it3)
iterators::nextElem(it3)
iterators::nextElem(it3)
iterators::nextElem(it3)

itertools2 documentation built on May 30, 2017, 7:17 a.m.