Added nargin function

This commit is contained in:
Waldir Leoncio 2020-10-19 09:49:30 +02:00
parent 03089d7e42
commit 3250349c60
3 changed files with 43 additions and 5 deletions

View file

@ -3,9 +3,8 @@
#' @return An integer
#' @author Waldir Leoncio
#' @note This function only makes sense inside another function
#' @references https://stackoverflow.com/q/64422780/1169233
nargin <- function() {
# FIXME: returning 0 because it is using its own envir instead of parent's
print(parent.env(environment()))
length(as.list(match.call(envir = parent.env(environment())))) - 1
# length(ls(envir=parent.env(environment()))) - 1
}
if(sys.nframe() < 2) stop("must be called from inside a function")
length(as.list(sys.call(-1))) - 1
}