as_iterator | R Documentation |
as_iterator()
is a generic function that transforms its input to
an iterator function. The default implementation
is as follows:
Functions are returned as is.
Other objects are assumed to be vectors with length()
and [[
methods.
Methods must return functions that implement coro's iterator protocol.
as_iterator()
is called by coro on the RHS of in
in for
loops. This applies within generators, async functions, and loop()
.
as_iterator(x)
## Default S3 method:
as_iterator(x)
x |
An object. |
An iterable function.
as_iterator(1:3)
i <- as_iterator(1:3)
loop(for (x in i) print(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.