power: Parent Function: Power of a number.

View source: R/helpers.R

powerR Documentation

Parent Function: Power of a number.

Description

This is an internal function to generate another ones which will be effectivelly exported. This function is not exported in NAMESPACE, therefore it is not available for the end-user.

Usage

power(exponent)

Arguments

exponent

The exponent.

Value

A parent function that allows the user to create a closure that returns the n-th power of its argument.

Examples


## Not run: 
power <- function(exponent) {
function(x) {
  x ^ exponent
}
}

square <- power(2)
square_root <- power(.5)

square(2) #4
square_root(4) #2

## End(Not run)

lfpdroubi/appraiseR documentation built on April 14, 2024, 10:27 p.m.