generate_AndOr {lazy.tools}R Documentation

Generation of character infix operators: '&', '&&', '|', '||'

Description

Generation of character infix operators: '&', '&&', '|', '||'

Usage

generate_AndOr()

Details

This function generates infix operators: '&', '&&', '|', '||' in the global environment,
which are almost equivalent to, resp, '%&%', '%&&%', '%|%', '%||%' .
The difference is that '&' has precedence over '|' but '%&%' does NOT.
For example:

"a" | "b" & "c" produces "(a) | ((b) & (c))"
but
"a" %|% "b" %&% "c" produces "((a) | (b)) & (c)" .

See the examples below.

"a" & "b" is equivalent to And( "a", "b" ) and generates "(a) & (b)".
"a" && "b" is equivalent to And( "a", "b", oper="&&" ) and generates "(a) && (b)".
"a" | "b" is equivalent to Or( "a", "b" ) and generates "(a) | (b)".
"a" || "b" is equivalent to Or( "a", "b", oper="||" ) and generates "(a) || (b)".

Use eval( parse(text=condition) ) to evaluate the expression.

To remove these operators:
rm( `&`, `&&`, `|`, `||` )

Value

Generates four infix operators in the global environment.

Examples

generate_AndOr()

"a" & "b"
"a" %&% "b"
And( "a", "b" )
"a" | "b"
"a" %|% "b"
Or( "a", "b" )

# precedences
"a" | "b" & "c"
"a" %|% "b" %&% "c"

"a" & "b" | "c"
"a" %&% "b" %|% "c"



[Package lazy.tools version 0.1.3 Index]