Re: [R] detecting entry into a recursive function

2013-02-17 Thread Jim Lemon
On 02/18/2013 02:03 AM, Benjamin Tyner wrote: Thanks Jim -- I had considered this approach; is there any way to "hide" such arguments from users? Hi Ben, I played around with your solution for a while and if the first argument to the function changes with each recursive call, you may be able t

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Duncan Murdoch
On 13-02-17 10:03 AM, Benjamin Tyner wrote: Thanks Jim -- I had considered this approach; is there any way to "hide" such arguments from users? Don't export the recursive function, just a non-recursive function that calls it. Duncan Murdoch Jim Lemon wrote: On 02/17/2013 12:55 PM, Benjam

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Bert Gunter
Make the flag an attribute of the function? Unless the user looks at the attributes, it will be "invisible." (Not sure this does what you want, but maybe it's useful.) -- Bert On Sun, Feb 17, 2013 at 7:03 AM, Benjamin Tyner wrote: > Thanks Jim -- I had considered this approach; is there any wa

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Benjamin Tyner
Thanks Jim -- I had considered this approach; is there any way to "hide" such arguments from users? Jim Lemon wrote: On 02/17/2013 12:55 PM, Benjamin Tyner wrote: Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint <- fun

Re: [R] detecting entry into a recursive function

2013-02-16 Thread Jim Lemon
On 02/17/2013 12:55 PM, Benjamin Tyner wrote: Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint <- function(){ par <- sys.call(-1L)[[1]] grandpar <- sys.call(-2L)[[1]] !identical(par, grandpar) } but this won't work for

[R] detecting entry into a recursive function

2013-02-16 Thread Benjamin Tyner
Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint <- function(){ par <- sys.call(-1L)[[1]] grandpar <- sys.call(-2L)[[1]] !identical(par, grandpar) } but this won't work for functions that don't directly