get_postfix_rule: Changes a logical expression in infix notation to postfix...

View source: R/domain.R

get_postfix_ruleR Documentation

Changes a logical expression in infix notation to postfix notation using the shunting-yard algorithm.

Description

Changes a logical expression in infix notation to postfix notation using the shunting-yard algorithm.

Usage

get_postfix_rule(rule, num_eqs)

Arguments

rule

A string containing positive integers, parentheses, and "&" and "|" only. "&&" and "&" are not differentiated, and similarly for "||" and "|". Chained operations are only allowed for the same operation ("&" or "|"), so instead of "1 && 2 || 3" one should write either "(1 && 2) || 3" or "1 && (2 || 3)" to avoid ambiguity.

num_eqs

An integer, must be larger than or equal to the largest integer appearing in rule.

Details

Applied to domain$rule if domain$type == "polynomial", and internally calls beautify_rule().

Value

rule in postfix notation.

Examples

get_postfix_rule("1 & 2 && 3", 3)
get_postfix_rule("1 & (2 || 3)", 3)
get_postfix_rule("(1 & 2) || 3 | (4 & (5 || 6) && 7) | 8 | (9 && (10 || 11 | 12) & 13)", 13)
## Not run: 
get_postfix_rule("1 && 2 & 3 && 4", 3) # Error, ineq number 4 appearing in \code{rule}.

## End(Not run)
## Not run: 
# Error, ambigious rule. Change to either \code{"1 & (2 | 3)"} or \code{"(1 & 2) | 3"}.
get_postfix_rule("1 & 2 | 3", 3)

## End(Not run)

genscore documentation built on May 29, 2024, 9 a.m.