Skip to contents

This function is the labeller for find_div_pairs()

Usage

label_pairs(pairs, n_tags, reverse = FALSE)

Arguments

pairs

a vector of parentheses.

n_tags

the number of closing tags

reverse

if TRUE, the search from the end of the stack

Value

a vector of integers indicating the pair of parentheses.

Examples


x <- c("(", "(", ")", ")")
pegboard:::label_pairs(x, 2)
#> [1] 1 2 2 1
x <- c("(", "(", ")", "(", "(", ")", ")", ")")
pegboard:::label_pairs(x, 4)
#> [1] 1 2 2 3 4 4 3 1