Finds the value of the next iteration(s) of an Iterator object
and increments the Iterator to the next value(s). yield_more()
repeats
yield_next()
a specified number of times.
Refer to the number of the current iteration in yield_more()
with .iter
.
yield_next(iter) yield_more(iter, more = 1L)
iter | An Iterator object |
---|---|
more | How many values to yield |
An object of whatever type result
evaluates to from the Iterator, or
a vector of that type in the case of yield_more(iter, more > 1L)
.
primes <- 2:10000 %>% that_for_all(range(2, .x)) %>% we_have(~.x %% .y != 0, "Iterator") sequence <- yield_more(primes, 100) # use `.iter` to reference the current iteration rwd <- Iterator({ set.seed(seeds[.iter]) n <- n + sample(c(-1L, 1L), size = 1L, prob = c(0.25, 0.75)) }, initial = list(n = 0, seeds = 1:100), yield = n) yield_more(rwd, 100)#> [1] 1 2 3 4 5 6 7 6 7 8 9 10 11 12 13 14 15 16 15 16 15 14 15 16 17 #> [26] 18 19 18 19 20 21 22 23 24 25 24 25 26 27 28 29 30 29 30 31 32 33 32 33 34 #> [51] 35 34 35 36 35 36 37 38 39 40 39 40 39 38 39 40 39 38 37 38 39 40 39 40 41 #> [76] 42 43 44 43 42 43 44 45 46 45 46 45 46 47 48 49 50 51 52 51 52 53 54 55 56