Re: [R] Parallel assignments and goto

2018-02-27 Thread Thomas Mailund
I did try assign. That was the slowest version from what my profiling could tell, as far as I recall, which really surprised me. I had expected it to be the fastest. The second slowest was using the [[ operator on environments. Or it might be the reverse for those two. They were both slower than

Re: [R] Parallel assignments and goto

2018-02-27 Thread Bert Gunter
No clue, but see ?assign perhaps if you have not done so already. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Feb 27, 2018 at 6:51 AM, Thomas

Re: [R] Parallel assignments and goto

2018-02-27 Thread Thomas Mailund
Interestingly, the <<- operator is also a lot faster than using a namespace explicitly, and only slightly slower than using <- with local variables, see below. But, surely, both must at some point insert values in a given environment — either the local one, for <-, or an enclosing one, for <<- —

Re: [R] Parallel assignments and goto

2018-02-26 Thread Thomas Mailund
Following up on this attempt of implementing the tail-recursion optimisation — now that I’ve finally had the chance to look at it again — I find that non-local return implemented with callCC doesn’t actually incur much overhead once I do it more sensibly. I haven’t found a good way to handle par

Re: [R] Parallel assignments and goto

2018-02-14 Thread Fox, John
e- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas > Mailund > Sent: Sunday, February 11, 2018 10:49 AM > To: r-help@r-project.org > Subject: [R] Parallel assignments and goto > > Hi guys, > > I am working on some code for automatically

Re: [R] Parallel assignments and goto

2018-02-11 Thread Thomas Mailund
I admit I didn’t know about Recall, but you are right, there is no direct support for this tail-recursion optimisation. For good reasons — it would break a lot of NSE. I am not attempting to solve tail-recursion optimisation for all cases. That wouldn’t work by just rewriting functions. It might

Re: [R] Parallel assignments and goto

2018-02-11 Thread David Winsemius
> On Feb 11, 2018, at 7:48 AM, Thomas Mailund wrote: > > Hi guys, > > I am working on some code for automatically translating recursive functions > into looping functions to implemented tail-recursion optimisations. See > https://github.com/mailund/tailr > > As a toy-example, consider the fa

[R] Parallel assignments and goto

2018-02-11 Thread Thomas Mailund
Hi guys, I am working on some code for automatically translating recursive functions into looping functions to implemented tail-recursion optimisations. See https://github.com/mailund/tailr As a toy-example, consider the factorial function factorial <- function(n, acc = 1) { if (n <= 1) ac