idiv {iterors}R Documentation

Dividing Iterator

Description

Returns an iterator dividing a value into integer chunks, such that sum(idiv(n, ...)) == floor(n)

Usage

idiv(count, ..., recycle = FALSE, chunkSize, chunks)

Arguments

count

The total

...

Unused.

recycle

Whether to restart the count after finishing.

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.

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.

Details

Originally from the iterators package.

Value

The dividing iterator.

Examples


# divide the value 10 into 3 pieces
it <- idiv(10, chunks = 3)
nextOr(it)
nextOr(it)
nextOr(it)
nextOr(it, NULL)  # expect NULL

# divide the value 10 into pieces no larger than 3
it <- idiv(10, chunkSize = 3)
nextOr(it)
nextOr(it)
nextOr(it)
nextOr(it)
nextOr(it, NULL)  # end of iterator


[Package iterors version 1.0 Index]