Skip to content

Commit

Permalink
In composite function invocation, name arguments following dots (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
egnha committed Jun 6, 2018
1 parent cb55e1a commit 3d18b58
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion R/compose.R
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,26 @@ fuse <- function(fs) {

reduce_calls <- function(n, fmls) {
nms <- as_protected_name(seq_len(n))
args <- lapply(names(fmls), as.name)
args <- signature(fmls)
expr <- as.call(c(as.name(nms[[1L]]), args))
for (nm in nms[-1L])
expr <- call(nm, expr)
list(expr = expr, nms = nms)
}

signature <- local({
dots <- quote(...)
as_names <- function(xs) lapply(xs, as.name)

function(fmls) {
nms <- names(fmls)
i <- which(nms == "...")
if (is_empty(i))
return(as_names(nms))
c(as_names(nms[seq_len(i - 1L)]), dots, eponymous(nms[-seq_len(i)]))
}
})

get_tree <- function(fs, env) {
force(env)
nms <- fn_names(fs)
Expand Down

0 comments on commit 3d18b58

Please sign in to comment.