1
#' Extract function(s) from a functional sequence.
2
#'
3
#' Functional sequences can be subset using single or double brackets.
4
#' A single-bracket subset results in a new functional sequence, and 
5
#' a double-bracket subset results in a single function. 
6
#'
7
#' @rdname fseq
8
#' @param x A functional sequence
9
#' @param ... index/indices. For double brackets, the index must be of length 1.
10
#' @return A function or functional sequence.
11
#' @export
12
`[[.fseq` <- function(x, ...)
13
{
14 0
  functions(x)[[...]]
15
}
16

17
#' @rdname fseq
18
#' @export
19
`[.fseq` <- function(x, ...)
20
{
21 0
  y  <- x
22 0
  environment(y) <- new.env(parent = parent.env(environment(x)))
23 0
  environment(y)[["_function_list"]] <- functions(x)[...]
24 0
  y
25
}

Read our documentation on viewing source code .

Loading