gen.logical.and
Generate Logical Conditions with List Comprehension
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.
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
.
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.
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
# 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))
# }