listcompr (version 0.1.0)

gen.logical.and: Generate Logical Conditions with List Comprehension

Description

Functions to compose and-/or-connected logical conditions, based on variable ranges and additional conditions.

Usage

gen.logical.and(expr, ...)

gen.logical.or(expr, ...)

Arguments

expr

A base expression which is partially evaluated for all combinations of variables. It may still contain free variables.

...

Arbitrary many variable ranges and conditions.

Value

Returns an expression expr_1 & ... & expr_n or expr_1 | ... | expr_n where expr_i is generated from expr, where all free variables are substituted for which a range is given. The other variables remain untouched.

The generated condition may be used within the the conditions of gen.list and similar functions from this package.

Details

See gen.list for more details on the expr and ... parameters.

For variables with underscores additionally the evaluation of indices in ()-brackets is supported. For example, an expression x_(i+1) is evaluated as x_3 for i = 2.

See Also

gen.list to generate lists and thereby make use of the generated logical conditions, and listcompr for an overview of all list comprehension functions.

Examples

Run this code
# NOT RUN {
# Returns a_1 == 1 & a_2 == 2 & a_3 == 3
gen.logical.and(a_i == i, i = 1:3)

# Get all permutations of 1:4
gen.data.frame(c(a_1, ..., a_4), a_ = 1:4, gen.logical.and(a_i != a_j, i = 1:4, j = (i+1):4))

# }

Run the code above in your browser using DataCamp Workspace