R/util.R

Defines functions end_iteration iteration_has_ended new_iterator is.iterator

Documented in end_iteration is.iterator iteration_has_ended new_iterator

# 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, 6:16 p.m.