read_one_term: Parses the first term of a non-uniform expression.

View source: R/domain.R

read_one_termR Documentation

Parses the first term of a non-uniform expression.

Description

Parses the first term of a non-uniform expression.

Usage

read_one_term(s)

Arguments

s

A string, the variable side of a non-uniform inequality expression (i.e. terms must be rewritten in e.g. x1, x2 as opposed to x).

Details

Parses the first term in a non-uniform expression and returns the rest of the terms.

Value

A list containing the following elements:

idx

An integer, the index of the first term (e.g. 3 for 1.3*x3^(-2/5))).

power_numer

An integer, the power_numer of the first term.

power_denom

An integer, the power_denom of the first term.

coef

A number, the coefficient on the first term (e.g. 1.3 for 1.3*x3^(-2/5)).

s

A string, the rest of the unparsed string.

Examples

read_one_term("0.5*x1+x2^2")
read_one_term("2e3x1^(2/3)-1.3x2^(-3)")
read_one_term("2exp(3x1)+2.3*x2^2")
read_one_term(paste(sapply(1:10, function(j){paste(j, "x", j, "^", (11-j), sep="")}), collapse="+"))
read_one_term("0.5*x1^(-2/3)-x3^3 + 2log(x2)- 1.3e4exp(-25*x6)+x8-.3x5^(-3/-4)")
read_one_term("-1e-4x1^(-2/3)-x2^(4/-6)+2e3x3^(-6/9) < 3.5e5")

genscore documentation built on May 31, 2023, 6:28 p.m.