find
Returns the first element matching the predicate, or null if no match is found. findLast searches from the end of the array.
Signatures
inline fun <T, D : Dimension> MultiArray<T, D>.find(
predicate: (T) -> Boolean
): T?
inline fun <T, D : Dimension> MultiArray<T, D>.findLast(
predicate: (T) -> Boolean
): T?
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Condition to test each element against. |
Returns: The first (or last) matching element, or null if no element matches.
Example
val a = mk.ndarray(mk[1, 2, 3, 4, 5])
a.find { it > 3 } // 4
a.findLast { it > 3 } // 5
a.find { it > 10 } // null
28 February 2026