Collection
An ordered heterogeneous collection of parser entities.
The constructor retains the supplied array and its element references.
getElements likewise exposes the live backing array. Use copy
for an independent collection; it copies every contained parser entity.
each and indexed assignment mutate the collection. A callback passed
to each may return a replacement value or return nothing to leave the
current value unchanged. Use forEach for observation-only iteration.
Evaluation and expansion operate on a deep copy. Equality and relational
predicates compare corresponding elements and return false for a non-Collection
or length mismatch; these component-wise predicates do not define a
lexicographic ordering for heterogeneous values.
Members
__get__(indices: number[]): ParserEntityMethodReturns the element at the given index.
Parameters
| Name | Type | Description |
|---|---|---|
indices | number[] | A single-element array [i] |
Returns
__set__(indices: number[], value: ParserEntity): voidMethodSets the element at the given index.
Parameters
| Name | Type | Description |
|---|---|---|
indices | number[] | A single-element array [i] |
value | ParserEntity | The value to set |
Returns
void
[iterator](): Iterator<ParserEntity>MethodIterates over the stored entity references in insertion order.
Returns
Iterator<ParserEntity>
abs(): CollectionMethodNo description is available yet.
Returns
at(index: number): ParserEntity | undefinedMethodReturns the stored entity reference at a zero-based index, or undefined when absent.
Parameters
| Name | Type | Description |
|---|---|---|
index | number | — |
Returns
ParserEntity | undefined
buildFunction(argsArray?: string[]): (...args: number[]): numberMethodCompiles this value to a native JavaScript-number function when the parsed result
is an Expression.
Structured parser results expose this method so values returned by nerdamer(...)
have one consistent TypeScript surface, but they cannot be compiled as scalar
functions and throw core!UnexpectedDataType when called.
Parameters
| Name | Type | Description |
|---|---|---|
argsArray | string[] | Optional variable names in positional call order. |
Returns
(...args: number[]): number — A JavaScript-number function compiled from the scalar expression.
Collection(elements?: ParserEntity[]): CollectionConstructorCreates a Collection, retaining elements when it is supplied.
Parameters
| Name | Type | Description |
|---|---|---|
elements | ParserEntity[] | Initial backing array. |
Returns
copy(): CollectionMethodCopies the collection and every contained entity.
Returns
count(): numberMethodReturns the number of values in the collection.
Returns
number
dataType: "COL"PropertyRuntime type discriminator for collections.
diff(variable?: ExpressionInput, n?: number | Expression): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
n | number | Expression | — |
Returns
dimensions(): number[]MethodReturns the collection length as a one-dimensional shape.
Returns
number[]
dimensionsMatch(x: ParserEntity): xMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | — |
Returns
x
div(x: NerdamerInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
each(callback: (a: ParserEntity, b: number): void | ParserEntity): thisMethodVisits or replaces values in ascending index order.
Returning a ParserEntity replaces the current value. Returning void leaves
that value unchanged, so callers can inspect a collection without a dummy return.
Use forEach when no transformation is intended.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (a: ParserEntity, b: number): void | ParserEntity | Function receiving each value and index. |
Returns
this
elements: ParserEntity[]PropertyLive array containing the collection's values.
eq(x: ParserEntity): booleanMethodTests whether another Collection has equal values in the same order.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to compare. |
Returns
boolean
evaluate(): CollectionMethodEvaluates a copied collection, leaving this one unchanged.
Returns
expand(): CollectionMethodExpands every value in a copied collection.
Returns
factor(): CollectionMethodNo description is available yet.
Returns
forEach(callback: (value: ParserEntity, index: number): void): voidMethodVisits stored entity references without changing the collection.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (value: ParserEntity, index: number): void | — |
Returns
void
getElements(): ParserEntity[]MethodReturns the live backing array; mutations to it affect this Collection.
Returns
gt(x: ParserEntity): booleanMethodTests whether every value is greater than its corresponding value.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to compare. |
Returns
boolean
gte(x: ParserEntity): booleanMethodTests component-wise greater-than-or-equal comparison.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to compare. |
Returns
boolean
integrate(variable?: ExpressionInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
Returns
isCollection(obj: unknown): objMethodReturns whether a value is a Collection.
Parameters
| Name | Type | Description |
|---|---|---|
obj | unknown | Value to test. |
Returns
obj
isEnumerable: booleanPropertyIndicates that parser operations may be applied to each element.
lt(x: ParserEntity): booleanMethodTests whether every value is less than its corresponding value.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to compare. |
Returns
boolean
lte(x: ParserEntity): booleanMethodTests component-wise less-than-or-equal comparison.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to compare. |
Returns
boolean
minus(x: NerdamerInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
numeric(precision?: ExpressionInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
precision | ExpressionInput | — |
Returns
plus(x: NerdamerInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
pow(x: NerdamerInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
precision: numberPropertyPrecision metadata when the collection carries an approximate result.
simplify(): CollectionMethodNo description is available yet.
Returns
subst(value: ExpressionInput, withValue: ExpressionInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
value | ExpressionInput | — |
withValue | ExpressionInput | — |
Returns
text(): stringMethodReturns the collection in Nerdamer notation.
Returns
string
times(x: NerdamerInput): CollectionMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
toArray(): ParserEntity[]MethodReturns a new array containing the stored entity references in insertion order.
Returns
toString(): stringMethodNo description is available yet.
Returns
string
