Extract a single code block from a slimr_script

get_block(x, i)

Arguments

x

slimr_script object to extract block from

i

The block to extract. Can be either an integer specifying what block(s) index to extract, or a character, in which case it pulls the block(s) with the corresponding name.

Examples

script <- slim_script(
  slim_block_init_minimal(),
  slim_block_finish(100)
)
get_block(script, "block_init")
#> <slimr_script[1]>
#> block_init:initialize() {
#>     initializeMutationRate(1e-07);
#>     initializeMutationType("m1", 0.5, "f", 0);
#>     initializeGenomicElementType("g1", m1, 1);
#>     initializeGenomicElement(g1, 0, 1e+05 - 1);
#>     initializeRecombinationRate(1e-08);
#> }
get_block(script, 2)
#> <slimr_script[1]>
#> block_2:100 early() {
#>     sim.simulationFinished();
#> }