Element-wise selection based on a boolean predicate, mirroring R's
ifelse(). For each element, returns the corresponding element from
yes where test is TRUE and from no where test is FALSE.
prim_if() is the other conditional: it mirrors R's if construct and
branches between two functions, evaluating only the selected one.
Arguments
- test
(
arrayish)
Predicate array. Must be a boolean or an R logical, and scalar or the same shape asyes.- yes, no
(
arrayish)
Values to select from, of the same shape. Can be any data type.yesandnomust have the same data type. An R value among them assumes the data type of the others when it is in its data type category, and its default data type when none of them has one.
Value
(arrayish)
Has the shape of yes and no, and the data type they agreed on.
StableHLO
Lowers to hlo_select(), specified under
select.