Learn R Programming

tm (version 0.3-3)

FunctionGenerator: Function Generator Constructor

Description

Constructs a function generator object.

Usage

## S3 method for class 'function':
FunctionGenerator(object)

Arguments

object
a generator function which takes some input and constructs and returns a new function based on that input information.

Value

  • An S4 object of class FunctionGenerator which extends the class function representing a function generator.

See Also

Many reader functions are function generators, e.g., readPlain.

Examples

Run this code
funGen <- FunctionGenerator(function(y, ...) {
if (is(y, "integer")) function(x) x+1 else function(x) x-1
})
funGen
funGen(3L)
funGen("a")

Run the code above in your browser using DataLab