Bring back rerun(), or adjust map()?
lmiratrix opened this issue · comments
I run a lot of simulations, and relied heavily on rerun(). The current view is this should be replaced with map( 1:R, ~ one_run() ) rather than rerun( R, one_run() ). But this makes it hard to pass arguments through to one_run() since the map version makes the anonymous function take an extra ID number, which is often not particularly useful for the one_run() call.
E.g., consider passing through triple dots like this:
func = function( x, ... ) {
cat( "func - x = ", x, "\n" )
print( list( ... ) )
}
func_wrap <- function( r, ... ) {
cat( "func_wrap:\n" )
print( list( ... ) )
func( 10, ... )
res <- map( r:(r+1), ~ {
cat( "** map tick\n" )
func( x=4, ... ) } )
invisible( res )
}
func_wrap( 4, a=2, b=3 )
This has ties to the behavior noted in #1118 (which I flagged before, but this keeps coming up for me--I am posting this as it seems a different take on the original issue)