Package 'partialised'

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

Help Index


Argument lists for partialised functions

Description

Argument lists for partialised functions

Usage

arguments(x)

arguments(x) <- value

Arguments

x

Partialised function.

value

A list of arguments.

Value

arguments() returns a list of arguments.


Extract or replace arguments for partialised functions

Description

Extract or replace arguments for partialised functions

Usage

## 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

Arguments

x

Partialised function.

i

Indices specifying arguments to extract or replace.

...

Additional arguments.

value

An object, the new value of the argument.

Value

[, [[ and $ return arguments.


Create partialised functions

Description

Create partialised functions

Usage

new_partialised(f, args = list(), ..., class = character())

Arguments

f

A function.

args

A list of default arguments.

...

Additional arguments for attributes.

class

Name of subclass.

Value

A partialised function.

See Also

purrr::partial()

Examples

dist <- function(x, y) {
  sqrt(x ^ 2 + y ^ 2)
}
pdist <- new_partialised(dist,
                         list(x = 3))
pdist(y = 4)