search for: factorial_tr_2

Displaying 6 results from an estimated 6 matches for "factorial_tr_2".

Did you mean: factorial_tr_1
2018 Feb 11
4
Parallel assignments and goto
...so the expression uses the old variable values and not the new values until the assignments are all done ? and one related to restarting a loop from nested loops or from nested expressions in `with` expressions or similar. I can implement parallel assignment using something like rlang::env_bind: factorial_tr_2 <- function (n, acc = 1) { .tailr_env <- rlang::get_env() repeat { if (n <= 1) return(acc) else { rlang::env_bind(.tailr_env, n = n - 1, acc = acc * n) next } } } This reduces the number of additional variables I ne...
2018 Feb 11
0
Parallel assignments and goto
...ses the old variable values and not the new values until the assignments are all done ? and one related to restarting a loop from nested loops or from nested expressions in `with` expressions or similar. > > I can implement parallel assignment using something like rlang::env_bind: > > factorial_tr_2 <- function (n, acc = 1) > { > .tailr_env <- rlang::get_env() > repeat { > if (n <= 1) > return(acc) > else { > rlang::env_bind(.tailr_env, n = n - 1, acc = acc * n) > next > } > } > } > &...
2018 Feb 14
0
Parallel assignments and goto
...; factorial_tr_3 <- function (n, acc = 1) { + repeat { + if (n <= 1) + return(acc) + else { + passign(n = n - 1, acc = acc * n) + next + } + } + } > microbenchmark::microbenchmark(factorial(100), + factorial_tr_1(100), + factorial_tr_2(100), + factorial_tr_3(100)) Unit: microseconds expr min lq mean median uq max neval cld factorial(100) 55.009 69.290 100.4507 104.5515 131.174 228.496 100 a factorial_tr_1(100) 10.227 11.637 14.4967 13.7530...
2018 Feb 26
0
Parallel assignments and goto
...uses the old variable values and not the new values until the assignments are all done ? and one related to restarting a loop from nested loops or from nested expressions in `with` expressions or similar. > > I can implement parallel assignment using something like rlang::env_bind: > > factorial_tr_2 <- function (n, acc = 1) > { > .tailr_env <- rlang::get_env() > repeat { > if (n <= 1) > return(acc) > else { > rlang::env_bind(.tailr_env, n = n - 1, acc = acc * n) > next > } > } > } > > This reduces the number of additional variables I need to one,...
2018 Feb 27
2
Parallel assignments and goto
...le values and not the new values until the assignments are all done ? and one related to restarting a loop from nested loops or from nested expressions in `with` expressions or similar. > > > > I can implement parallel assignment using something like rlang::env_bind: > > > > factorial_tr_2 <- function (n, acc = 1) > > { > > .tailr_env <- rlang::get_env() > > repeat { > > if (n <= 1) > > return(acc) > > else { > > rlang::env_bind(.tailr_env, n = n - 1, acc = acc * n) > > next > > } > > } > > } > > > &g...
2018 Feb 27
0
Parallel assignments and goto
...til the assignments are all done ? and one > related to restarting a loop from nested loops or from nested expressions > in `with` expressions or similar. > > > > > > I can implement parallel assignment using something like > rlang::env_bind: > > > > > > factorial_tr_2 <- function (n, acc = 1) > > > { > > > .tailr_env <- rlang::get_env() > > > repeat { > > > if (n <= 1) > > > return(acc) > > > else { > > > rlang::env_bind(.tailr_env, n = n - 1, acc = acc * n) > > > next > > &gt...