R/nodoc.R

Defines functions `[.VecGen` `[.Comprehension`

#' @export
`[.Comprehension` <- function(COMPREHENSION, obj, ...){
  mapfun <- attr(COMPREHENSION, "mapfun")
  fun  <- attr(COMPREHENSION, "fun")
  ret <- eval(parse(text=.parse_for(substitute(obj), mapfun=mapfun, ...)))
  if (is.null(fun)) return(ret)
  fun(ret)
}


#' @export
`[.VecGen` <- function(VECTORGENERATOR, ..., type=Vec, simplify=TRUE){
  dots <- eval(substitute(alist(...)))
  mapfun <- attr(type, "mapfun")
  fun <- attr(type, "fun")
  l <- lapply(dots, function(i){
    e <- eval(parse(text=.parse_for(i, mapfun=mapfun)))
    if (is.null(fun)) return(e)
    fun(e)
  })
  if (length(dots) == 1) return(l[[1]])
  if (simplify) return(Reduce(c, l))
  l
}

Try the eList package in your browser

Any scripts or data that you put into this service are public.

eList documentation built on Jan. 23, 2021, 1:05 a.m.