Conditional execution of one of two branches based on a scalar boolean
predicate. Unlike prim_ifelse() which operates element-wise, this
evaluates only the selected branch.
Arguments
- pred
(
arrayish)
Predicate deciding which branch to execute. Must be a scalar of the boolean data type, or an R logical.- true, false
(
function())
Zero-argument functions for the true and false branches. Both must return outputs of the same structure, data types and shapes. As withprim_ifelse(), whose two values must already agree, nothing is promoted: branches that disagree are an error.
Value
(arrayish | list)
Result of the executed branch: an array, or a tree of them in the sense
of pjrt's RTree – a list, nested arbitrarily – with
the structure, data types and shapes both branches share.