Is the definition of a child function that will be called by the parent function inside the parent element (as a nested function) slower?
For example, suppose solution 1:
Foo <- function(x) {
Baz <- function(y) {
}
sapply(x, Baz)
}
or alternatively solution 2:
Baz <- function(y) {
}
Foo <- function(x) {
sapply(x, Baz)
}
In solution 1, there is an additional determination process Bazat startup Foo, so I assume that many of the calls Fooin solution 1 will be a bit slower. It's true?
source
share