MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / collectionIndexWhere

Function collectionIndexWhere

src/compute-engine/collection-utils.ts:153–168  ·  view source on GitHub ↗
(
  expr: Expression,
  predicate: (element: Expression) => boolean
)

Source from the content-addressed store, hash-verified

151 * diagnostic (`Union(Linspace(a, 1, 3), Set(1))` gave `Set(1)`).
152 *
153 * Use this predicate, not `isFiniteCollection`, before a walk of the
154 * elements (`each()`, `tally()`, an `at()` loop, a spread, a
155 * materialization). When it is `false`, the operator must decline (stay
156 * unevaluated). An `isEnumerableCollection` of `undefined` (an eager
157 * collection operator that is not evaluated yet) does not decline: the walk
158 * evaluates the source itself, which is the behavior these consumers always
159 * had.
160 *
161 * A finite collection that is provably empty (`isEmptyCollection === true`)
162 * is always walkable, even if `isEnumerableCollection` is `false`: the walk
163 * yields no elements, and that is the correct answer. `Linspace(a, 1, 0)`
164 * with a symbolic `a` has no elements, so `Union(Linspace(a, 1, 0), Set(1))`
165 * is `Set(1)`.
166 *
167 * `isEmptyCollection` is read only when `isEnumerableCollection` is `false`.
168 * For a lazy view, `isEmptyCollection` can compute the first element: the
169 * `isEmpty` handler of `Filter` applies the predicate until one element
170 * passes. This predicate is called while an expression is canonicalized
171 * (`isFiniteIndexedCollection`, from the argument checks of a numeric

Callers

nothing calls this directly

Calls 2

predicateFunction · 0.85
atMethod · 0.65

Tested by

no test coverage detected