inst/examples/iforever.R

library(iterors)

# return an iterator that returns the specified value forever
iforever <- function(x) {
  nextOr_ <- function(or) x
  iteror(nextOr_)
}

# create an iterator that returns 42 forever
it <- iforever(42)

# call it three times
for (i in 1:3)
  print(nextElem(it))

Try the iterors package in your browser

Any scripts or data that you put into this service are public.

iterors documentation built on May 31, 2023, 5:36 p.m.