On 10/25/06, Marc Schwartz <[EMAIL PROTECTED]> wrote: > On Wed, 2006-10-25 at 20:14 -0400, Gabor Grothendieck wrote: > > Suppose we have a function such as the following > > > > F <- function(f, x) f(x)+1 > > > > which runs function f and then transforms it. I would like the > > corresponding function which works the same except that > > unlike F returns an invisible result if and only if f does. > > > > Is there some way of determining whether f returns > > an invisible result or not? > > > > Thus we want this: > > > > f <- function(x) x > > g <- function(x) invisible(x) > > > > > F(f, 1) > > 2 > > > > > > > > F(g, 1) > > > > > Gabor, > > There may be a better way of doing this and/or this will spark some > thoughts. > > Let's create two simple functions: > > f.inv <- function(x) {invisible(x)} > > f <- function(x) {x} > > So we now have: > > > f.inv(1) > > f(1) > [1] 1 > > > > any(grep("invisible", (deparse(f)))) > [1] FALSE > > > any(grep("invisible", (deparse(f.inv)))) > [1] TRUE
That's not going to work, since invisibility can also be a side effect of assignment, e.g. g <- function(x) { x <- x } -Deepayan ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel