rebase: Alter a generators update function, spawning a new generator

Description Usage Arguments Details Examples

View source: R/rebase.R

Description

In general, it's not very good idea to alter the update of an generator. If a different update is needed, you can always write a new generator, and if one is needed in a chain of calls, wrapis usually a better option.

Usage

1
rebase(.generator, .FUN, .wrapper = get_wrapper(.generator))

Arguments

.generator

A function with the class generator

.FUN

A function to wrap the current update

.wrapper

A function to replace the current wrapper

Details

That said, when used appropriately, rebasing is very useful. For example, it powers several other tools in this package, like recycle.

Examples

1
2
3
4
counter <- generator(0, ~ state + 1)
times_two <- function(x) x * 2
skipping <- rebase(counter, times_two)
take(skipping, 5)

michaelquinn32/generators documentation built on May 22, 2019, 9:52 p.m.