Message-ID: <CAP01uRn3NTjO=uPN3Efqn4cekP94a9vXQO3aa2uojbjSmGFynQ@mail.gmail.com>
Date: 2013-02-04T16:31:06Z
From: Gabor Grothendieck
Subject: Modifying a function programmatically
In-Reply-To: <7E8037094A0C2146AA3E6F94DAE621C3444E97C8@AD-EXCHMBX2-3.aau.dk>
On Mon, Feb 4, 2013 at 5:00 AM, S?ren H?jsgaard <sorenh at math.aau.dk> wrote:
> Dear list
>
> # I have a function
> ff <- function(a,b=2,c=4){a+b+c}
> # which I programmatically want to modify to a more specialized function in which a is replaced by 1
> ff1 <- function(b=2,c=4){1+b+c}
>
This a currying operation. Try:
library(functional)
ff1 <- Curry(ff, a = 1)
# test
identical(ff1(2, 4), ff(1, 2, 4)) # TRUE
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com