We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I looked at the benchmarks, I was particularly surprised because I couldn't imagine the recursive fib being that fast compared to C.
The R recursion example is not an apples-to-apples comparison, because it is using two accumulators. In fact the commented out R code at https://github.com/JulesKouatchou/basic_language_comparison/blob/master/R/test_fibonacci.R#L15 is the right one. Or alternatively, all languages should use the one with two accumulators.
For example, here's the Julia version that does what the R version does and runs as fast.
function Fib(N) function F(N, a, b) N == 0 && return b F(N-1, a+b, a) end F(N, 1, 0) end
Much of this was done by @syxpek on the Julia slack. I am just reporting it.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I looked at the benchmarks, I was particularly surprised because I couldn't imagine the recursive fib being that fast compared to C.
The R recursion example is not an apples-to-apples comparison, because it is using two accumulators. In fact the commented out R code at https://github.com/JulesKouatchou/basic_language_comparison/blob/master/R/test_fibonacci.R#L15 is the right one. Or alternatively, all languages should use the one with two accumulators.
For example, here's the Julia version that does what the R version does and runs as fast.
Much of this was done by @syxpek on the Julia slack. I am just reporting it.
The text was updated successfully, but these errors were encountered: