Learn R Programming

factory (version 0.1.0)

build_factory: Easily Build Function Factories

Description

Easily Build Function Factories

Usage

build_factory(fun, ...)

Arguments

fun

An anonymous function to turn into a factory.

...

Arguments for the factory function. Things on the RHS will be evaluated before building your factory unless explicitly quoted with quote. See examples.

Value

A function factory.

Examples

Run this code
# NOT RUN {
y <- 2
power <- build_factory(
  fun = function(x) {
    x^exponent
  },
  exponent
)
square <- power(y)
square(2)
y <- 7
square(2)
# }

Run the code above in your browser using DataLab