| curry | R Documentation | 
curry() curries functions—it
reconstitutes a function as a succession of single-argument functions. For
example, curry() produces the the function
function(x) {
  function(y) {
    function(z) {
      x * y * z
    }
  }
}
from the function function(x, y, z) x * y * z.
curry_fn() produces a curried function from an fn()-style function
declaration, which supports quasiquotation of a
function’s body and (default) argument values.
curry(f, env = environment(f)) curry_fn(..., ..env = parent.frame())
f | 
 Function.  | 
env | 
 Environment of the curried function or   | 
... | 
 Function declaration, which supports quasiquotation.  | 
..env | 
 Environment in which to create the function (i.e., the function’s enclosing environment).  | 
Dots (...) are treated as a unit when currying. For example,
curry() transforms function(x, ...) list(x, ...) to
function(x) { function(...) list(x, ...) }.
A function of nested single-argument functions.
fn()
curry(function(x, y, z = 0) x + y + z)
double <- curry(`*`)(2)
double(3)  # 6
curry_fn(x, y, z = 0 ~ x + y + z)
curry_fn(target, ... ~ identical(target, ...))
## Delay unquoting to embed argument values into the innermost function
compare_to <- curry_fn(target, x ~ identical(x, QUQ(target)))
is_this <- compare_to("this")
is_this("that")  # FALSE
is_this("this")  # TRUE
classify_as <- curry_fn(class, x ~ `class<-`(x, QUQ(class)))
as_this <- classify_as("this")
as_this("Some object")  # String of class "this"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.