expand_array_indexes: Expand Array Indexes

View source: R/expand_array_indexes.R

expand_array_indexesR Documentation

Expand Array Indexes

Description

When submitting array jobs using sbatch, users can specify indices in several ways. These could be specified as, for example, ranges, "1-9", lists, "⁠1,2,5⁠", or intervals as "1-7:3", which translates into "⁠1, 4, 7⁠". This function expands those cases.

Usage

expand_array_indexes(x)

Arguments

x

A character vector. Array indexes (see details).

Details

x is assumed to be in the form of ⁠[jobid](_[array expression])⁠, where the expression after the underscore is optional. The first The function will return an expanded version of this, e.g. if x = "8123_[1,3-6]" the resulting expression will be the vector "8123_1", "8123_3", "8123_4", "8123_5", and "8123_6".

This function was developed mainly to be used internally.

Value

A character vector with the expanded indices.

Examples


expand_array_indexes(c("512", "123_1", "55_[1-5]", "122_[1, 5-6]", "44_[1-3:2]"))
# [1] "512"   "123_1" "55_1"  "55_2"  "55_3"  "55_4"  "55_5"
# "122_1" "122_5" "122_6" "44_1"  "44_3"

slurmR documentation built on Aug. 30, 2023, 5:06 p.m.