all
Tests whether every element in the array satisfies the given predicate. Returns true for empty arrays (vacuous truth), consistent with Kotlin's Iterable.all.
Signature
inline fun <T, D : Dimension> MultiArray<T, D>.all(
predicate: (T) -> Boolean
): Boolean
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Condition to test each element against. |
Returns: true if every element satisfies predicate. Returns true for empty arrays.
Example
val a = mk.ndarray(mk[2, 4, 6, 8])
a.all { it % 2 == 0 } // true
a.all { it > 5 } // false
val empty = mk.ndarray(mk[0]).drop(1)
empty.all { it > 0 } // true (vacuously true)
28 February 2026