Title: | Partialised Functions |
---|---|
Description: | Provides a 'partialised' class that extends the partialising function of 'purrr' by making it easier to change the arguments. This is similar to the function-like object in 'Julia' (<https://docs.julialang.org/en/v1/manual/methods/#Function-like-objects>). |
Authors: | Mizuki Uchida [aut, cre] |
Maintainer: | Mizuki Uchida <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-11-10 03:59:28 UTC |
Source: | https://github.com/uchidamizuki/partialised |
Argument lists for partialised functions
arguments(x) arguments(x) <- value
arguments(x) arguments(x) <- value
x |
Partialised function. |
value |
A list of arguments. |
arguments()
returns a list of arguments.
Extract or replace arguments for partialised functions
## S3 method for class 'partialised' x[i, ...] ## S3 replacement method for class 'partialised' x[i] <- value ## S3 method for class 'partialised' x[[i, ...]] ## S3 replacement method for class 'partialised' x[[i]] <- value ## S3 method for class 'partialised' x$i ## S3 replacement method for class 'partialised' x$i <- value
## S3 method for class 'partialised' x[i, ...] ## S3 replacement method for class 'partialised' x[i] <- value ## S3 method for class 'partialised' x[[i, ...]] ## S3 replacement method for class 'partialised' x[[i]] <- value ## S3 method for class 'partialised' x$i ## S3 replacement method for class 'partialised' x$i <- value
x |
Partialised function. |
i |
Indices specifying arguments to extract or replace. |
... |
Additional arguments. |
value |
An object, the new value of the argument. |
[
, [[
and $
return arguments.
Create partialised functions
new_partialised(f, args = list(), ..., class = character())
new_partialised(f, args = list(), ..., class = character())
f |
A function. |
args |
A list of default arguments. |
... |
Additional arguments for attributes. |
class |
Name of subclass. |
A partialised
function.
dist <- function(x, y) { sqrt(x ^ 2 + y ^ 2) } pdist <- new_partialised(dist, list(x = 3)) pdist(y = 4)
dist <- function(x, y) { sqrt(x ^ 2 + y ^ 2) } pdist <- new_partialised(dist, list(x = 3)) pdist(y = 4)