Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

idiv

Dividing Iterator


Description

Returns an iterator that returns pieces of numeric value.

Usage

idiv(n, ..., chunks, chunkSize)

Arguments

n

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

...

unused.

chunks

the number of pieces that n should be divided into. This is useful when you know the number of pieces that you want. If specified, then chunkSize should not be.

chunkSize

the maximum size of the pieces that n should be divided into. This is useful when you know the size of the pieces that you want. If specified, then chunks should not be.

Value

The dividing iterator.

Examples

# divide the value 10 into 3 pieces
  it <- idiv(10, chunks=3)
  nextElem(it)
  nextElem(it)
  nextElem(it)
  try(nextElem(it))  # expect a StopIteration exception

  # divide the value 10 into pieces no larger than 3
  it <- idiv(10, chunkSize=3)
  nextElem(it)
  nextElem(it)
  nextElem(it)
  nextElem(it)
  try(nextElem(it))  # expect a StopIteration exception

iterators

Provides Iterator Construct

v1.0.13
Apache License (== 2.0)
Authors
Michelle Wallig [cre], Revolution Analytics [aut, cph], Steve Weston [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.