Where did you come across the expression? It’s very likely that this is just to get you thinking about evaluations and booleans in R. Essentially, work inside of the parentheses and work outward until there is nothing left to evaluate. Let’s work through it step by step:
((111 >= 111) | !(TRUE)) & ((4 + 1) == 5)
Step 1:
(111 >= 111)
. Well, this is TRUE
because 111 == 111. So now we have the following (TRUE | !(TRUE)) & ((4 + 1) == 5)
.
Step 2:
!(TRUE)
. !
means “not” and simply reverses a boolean value. So, !TRUE
is the same as FALSE
and !FALSE
is the same as TRUE
. Therefore, we’re left with this: (TRUE | FALSE) & ((4 + 1) == 5)
.
Step 3:
(TRUE | FALSE)
. |
means “OR” and checks to see if at least one of the conditions is TRUE
. Here we have two condtions, TRUE
and FALSE
. Since one of them is TRUE
, this whole expression evaluates to TRUE
. We therefore now have TRUE & ((4 + 1) == 5)
.
Step 4:
((4 + 1) == 5)
. This is obviously TRUE
since 4 + 1 == 5
, so we now have TRUE & TRUE
.
Step 5:
TRUE & TRUE
. &
means “and” and it checks to see that all of the conditions are TRUE
. Since our two conditions are TRUE
and TRUE
, it’s true that all conditions are TRUE
and therefore this evaluates to TRUE
.
So, at the end of 5 steps of evaluation, we find that the entire expression evaluates to TRUE
. You’d benefit greatly from reading through the link @mtoto provided in the comments to help you understand this better.
Hope that helps.
1
solved What does ((111 >= 111) | !(TRUE)) & ((4 + 1) == 5) mean?