icount: Counting Iterators

Description Usage Arguments Value Examples

View source: R/extra.R

Description

Returns an iterator that counts starting from one.

Usage

1
2
icount(count)
icountn(vn)

Arguments

count

number of times that the iterator will fire. If not specified, it will count forever.

vn

vector of counts.

Value

The counting iterator.

Examples

1
2
3
4
5
6
  # create an iterator that counts from 1 to 3.
  it <- icount(3)
  nextElem(it)
  nextElem(it)
  nextElem(it)
  try(nextElem(it))  # expect a StopIteration exception

Example output

[1] 1
[1] 2
[1] 3
Error : StopIteration

iterators documentation built on Feb. 5, 2022, 1:06 a.m.