Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

undetermined number of arguments in function r

myfun <- function(x, ...) {
    for(i in list(...)) {
        print(x * i)
    }
}

d <- function(...){
    x <- list(...) // THIS WILL BE A LIST STORING EVERYTHING:
    sum(...)
}

// OUTPUT EXAMPLES
        
> d(1,2,3,4,5)
[1] 15 
               
> myfun(4, 3, 1)
[1] 12
[1] 4
> myfun(4, 9, 1, 0, 12)
[1] 36
[1] 4
[1] 0
[1] 48
> myfun(4)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #undetermined #number #arguments #function
ADD COMMENT
Topic
Name
9+3 =