View source: R/opt-cond-thread.R
opt_cond_thread | R Documentation |
Performs one conditional threading pass. Carefully examine the results after running this function!
opt_cond_thread(code)
code |
A list of character vectors with the code to optimize. |
code <- paste(
"num <- sample(100, 1)",
"even_sum <- 0",
"odd_sum_a <- 0",
"odd_sum_b <- 0",
"if (num %% 2 == 1) {",
" odd_sum_a <- odd_sum_a + num",
"}",
"if (num %% 2 == 1) {",
" odd_num_b <- odd_num_b + num",
"}",
"if (!(num %% 2 == 1)) {",
" even_sum <- even_sum + num",
"}",
sep = "\n"
)
cat(opt_cond_thread(list(code))$codes[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.