Returns an iterator that counts starting from one.

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

  # create an iterator that counts from 1 to 3.
  it <- icount(3)
  nextElem(it)
#> [1] 1
  nextElem(it)
#> [1] 2
  nextElem(it)
#> [1] 3
  try(nextElem(it))  # expect a StopIteration exception
#> Error : StopIteration