Conditional execution of two branches.
Unlike nv_ifelse(), which selects elements, this executes only one
of the two branches depending on a scalar predicate.
Arguments
- pred
(
arrayish)
Predicate. Must be a scalar of the boolean data type, or an R logical.- true
(
function())
Zero-argument function for the true branch.- false
(
function())
Zero-argument function for the false branch. Must return the same structure, data types and shapes as the true branch; nothing is promoted.
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.
See also
prim_if() for the underlying primitive, nv_ifelse() for
element-wise selection.