R/util.R

# This code was contributed by Hadley Wickham

end_iteration <- function() stop('StopIteration', call.=FALSE)

iteration_has_ended <- function(e) {
  identical(conditionMessage(e), 'StopIteration')
}

new_iterator <- function(nextElem, ...) {
  structure(list(nextElem=nextElem, ...), class=c('abstractiter', 'iter'))
}

is.iterator <- function(x) inherits(x, 'iter')

Try the itertools package in your browser

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

itertools documentation built on May 2, 2019, 2:26 p.m.