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

Function reduceCollection

src/compute-engine/library/collections.ts:3080–3093  ·  view source on GitHub ↗
(
  collection: Expression,
  fn: (acc: T, next: Expression) => T | null,
  initial: T
)

Source from the content-addressed store, hash-verified

3078// `Map((p1, …, pk) ↦ Tuple(…), s1, …, sk)` as built by `lazyBroadcastMap` for
3079// a large `PointList` — returning the source collection the projected slot
3080// binds to. `PointX(PointList(a, b, c))` is then just `a`: no per-element
3081// Tuple construction and `At` extraction on drain (Tycho item 52). Sound only
3082// when the slot is a plain parameter reference, every source is an INDEXED
3083// collection (the lazy-transpose contract — a `Map` over a `Set`, though it
3084// can look identical, must keep the generic path's indexed-`List` result),
3085// and every source has the same known count (`Map` zips to the shortest
3086// source, so projecting one source of a ragged zip would yield extra
3087// elements). Anything else returns `undefined` and the caller falls through
3088// to the generic path.
3089//
3090// Under `numericApproximation` the projection is returned as its lazy `.N()`
3091// form: the source itself is the EXACT collection (the transpose body's
3092// `N(…)` wrap belongs to the whole tuple, and is discarded with it), so
3093// returning it bare would let `PointX(pts).N()` yield exact elements —
3094// violating `x.N() ≡ x.evaluate().N()` parity.
3095function projectLazyPointList(
3096 xs: Expression,

Callers 2

reduceBigOpFunction · 0.90
collections.tsFile · 0.70

Calls 2

fnFunction · 0.85
eachMethod · 0.65

Tested by

no test coverage detected