forLoopToLapply: Transfrom For Loop To Lapply

Description Usage Arguments Details Value

View source: R/forLoop.R

Description

Determine if a for loop can be parallelized, and if so transform it into a call to lapply. This first version will modify loops if and only if the body of the loop does not do any assignments at all.

Usage

1
forLoopToLapply(forloop)

Arguments

forloop

R language object with class for.

Details

Recommended use case:

The functions in the body of the loop write to different files on each loop iteration.

The generated code WILL FAIL if:

Code in the body of the loop is truly iterative. Functions update global state in any way other than direct assignment.

Value

call R call to parallel::mclapply if successful, otherwise the original forloop.


clarkfitzg/codedoctor documentation built on Nov. 18, 2020, 4:34 p.m.