On 10/08/2016 12:53 PM, Thomas Mailund wrote:
> On 10 Aug 2016, at 13:56, Thomas Mailund <mail...@birc.au.dk> wrote:
>
> make_thunk <- function(f, ...) f(...)
Doh! It is of course this one:
make_thunk <- function(f, ...) function() f(…)
It just binds a function call into a thunk so I can delay its evaluation.
I haven't looked closely at the full set of functions, but this comment:
force(continuation) # if I remove this line I get an error
makes it sound as though you're being caught by lazy evaluation. The
"make_thunk" doesn't appear to evaluate ..., so its value can change
between the time you make the thunk and the time you evaluate it. I
think you could force the evaluation within make_thunk by changing it to
make_thunk <- function(f, ...) { list(...); function() f(…) }
and then would be able to skip the force() in your thunk_factorial function.
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.