Returns an iterator dividing a value into integer chunks, such that
sum(idiv(n, ...)) == floor(n)
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, thenchunks
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, thenchunkSize
should not be.
Examples
# divide the value 10 into 3 pieces
it <- idiv(10, chunks = 3)
nextOr(it)
#> [1] 4
nextOr(it)
#> [1] 3
nextOr(it)
#> [1] 3
nextOr(it, NULL) # expect NULL
#> NULL
# divide the value 10 into pieces no larger than 3
it <- idiv(10, chunkSize = 3)
nextOr(it)
#> [1] 3
nextOr(it)
#> [1] 3
nextOr(it)
#> [1] 3
nextOr(it)
#> [1] 1
nextOr(it, NULL) # end of iterator
#> NULL