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
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
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 <<- —
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
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
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
> 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
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
8 matches
Mail list logo