R/lastAdd.R

##
## Replaces the (defunct) addLast() function.
##
lastAdd <- function( fun )
  {
    if (!is.function(fun)) stop("fun must be a function")
    if(!exists(".Last", envir=.GlobalEnv))
      {
        return(fun)
      }
    else
      {
        Last <- get(".Last", envir=.GlobalEnv)
        newfun <- function(...)
          {
            fun()
            Last()
          }
        return(newfun)
      }
  }

Try the gtools package in your browser

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

gtools documentation built on May 2, 2019, 4:52 p.m.