Learn R Programming

functional (version 0.6)

Negate: Negate a function; borrowed from src/library/base/R/funprog.R for pre-2.7 Rs.

Description

Negate a function; borrowed from src/library/base/R/funprog.R for pre-2.7 Rs.

Usage

Negate(f)

Arguments

f
the function to be negated

Value

The negated function

Examples

Run this code
is.even <- function(a) a%%2 == 0
is.odd <- Negate(is.even)
stopifnot(Reduce(`&&`, Map(is.odd, c(1, 3, 5))))

Run the code above in your browser using DataLab