Description Usage Arguments Details Value Examples
Constructs a list of n
iterators, each of which iterates through an
iterable object
.
1 | itee(object, n = 2)
|
object |
an iterable object |
n |
the number of iterables to return |
If the object
is an iterator (i.e., inherits from class iter
),
n
deep copies of object
are returned. Otherwise, object
is passed to iter
n
times.
a list of n
iterators
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Creates a list of three iterators.
# Each iterator iterates through 1:5 independently.
iter_list <- itee(1:5, n=3)
# Consumes the first iterator
unlist(as.list(iter_list[[1]])) == 1:5
# We can iterate through the remaining two iterators in any order.
iterators::nextElem(iter_list[[2]]) # 1
iterators::nextElem(iter_list[[2]]) # 2
iterators::nextElem(iter_list[[3]]) # 1
iterators::nextElem(iter_list[[3]]) # 2
iterators::nextElem(iter_list[[2]]) # 3
iterators::nextElem(iter_list[[2]]) # 4
iterators::nextElem(iter_list[[2]]) # 5
iterators::nextElem(iter_list[[3]]) # 3
iterators::nextElem(iter_list[[3]]) # 4
iterators::nextElem(iter_list[[3]]) # 5
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.