Vector
An ordered, operable parser aggregate with heterogeneous ParserEntity elements.
Vector is not restricted to numeric linear-algebra values. General arithmetic
is element-wise: scalar operands are broadcast across the Vector, while Vector
operands are paired by position and must have the same length. Vector-to-Vector
times remains an element-wise product rather than an alias for dot.
A Matrix operand interprets this Vector as a row vector for the standard
Vector * Matrix product; orientation is supplied by operand position rather
than stored on the Vector.
Structural methods such as append, insert, extend,
reverse, and trim mutate this Vector.
True linear-algebra operations (dot, cross, and norm)
require Expression elements. dot requires equal lengths, while cross
requires two three-element Vectors. These operations throw rather than
assigning arithmetic meaning to arbitrary aggregate elements.
Construction from a Collection copies its elements. Construction from an
array normalizes inputs but retains existing parser entities; copy
deep-copies every element. Comparisons are component-wise predicates, not a
total ordering, and return false for a type or length mismatch.
Members
__get__(indices: number[]): ParserEntityMethodReturns the element at the given zero-based index. Used by the parser for bracket indexing, e.g. [a, b, c][1] returns b.
core!UnexpectedDataType If the index is out of bounds.
Parameters
| Name | Type | Description |
|---|---|---|
indices | number[] | Zero-based parser indices after index-base adjustment. |
Returns
ParserEntity — The stored parser entity.
__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>MethodReturns an iterator over the aggregate's current public element view.
Returns
Iterator<ParserEntity>
abs(): VectorMethodNo description is available yet.
Returns
add(x: ParserEntity): thisMethodAppends an existing parser entity by reference and returns this Vector.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | — |
Returns
this
append(e: ParserEntity): thisMethodAppends an existing parser entity by reference.
Parameters
| Name | Type | Description |
|---|---|---|
e | ParserEntity | Element to append. |
Returns
this
arrayMap(callback: (e: ParserEntity): unknown): unknown[]MethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (e: ParserEntity): unknown | — |
Returns
unknown[]
at(i: number): ParserEntity | undefinedMethodReturns the stored entity at a zero-based index without copying it.
Parameters
| Name | Type | Description |
|---|---|---|
i | number | Zero-based index. |
Returns
ParserEntity | undefined — The entity, or undefined when the index is out of range.
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.
clear(): thisMethodRemoves all elements from the vector.
Returns
this
Vector(elements?: Collection | NerdamerInput[]): VectorConstructorCreates a Vector from normalized input values or a copied Collection.
Parameters
| Name | Type | Description |
|---|---|---|
elements | Collection | NerdamerInput[] | — |
Returns
copy(): VectorMethodCopies the Vector and every contained entity.
Returns
count(): numberMethodGets the number of current elements in the Vector.
Returns
number — Current length.
create(v: ExpressionInput[]): VectorMethodCreates an Expression-only Vector from expression-compatible inputs.
Parameters
| Name | Type | Description |
|---|---|---|
v | ExpressionInput[] | — |
Returns
Computes the three-dimensional cross product.
core!DimensionError Unless both Vectors have exactly three elements.
core!UnexpectedDataType If any required element is not an Expression.
Parameters
| Name | Type | Description |
|---|---|---|
v | Vector | — |
Returns
dataType: "VEC"PropertyNo description is available yet.
delete(x: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | — |
Returns
boolean
diff(variable?: ExpressionInput, n?: number | Expression): VectorMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
n | number | Expression | — |
Returns
dimensions(): number[]MethodNo description is available yet.
Returns
number[]
dimensionsMatch(x: ParserEntity): xMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | — |
Returns
x
div(x: NerdamerInput): VectorMethodDivides corresponding elements, or broadcasts a scalar divisor.
Vector-to-Vector division is element-wise and requires equal lengths. This is distinct from scalar division, which applies the same divisor to every element.
core!DimensionError If a Vector divisor has a different length.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
dot(v: Vector): ExpressionMethodComputes the sum of pairwise products.
core!DimensionError If the Vector lengths differ.
core!UnexpectedDataType If a required element is not an Expression.
Parameters
| Name | Type | Description |
|---|---|---|
v | Vector | — |
Returns
each(callback: (e: ParserEntity, i: number): void | ParserEntity): thisMethodVisits or replaces elements in ascending index order.
Returning void leaves the current element unchanged.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (e: ParserEntity, i: number): void | ParserEntity | — |
Returns
this
elements: ParserEntity[]PropertyNo description is available yet.
eq(V: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
V | ParserEntity | — |
Returns
boolean
evaluate(values?: ParserValuesObject): VectorMethodEvaluates and returns a copied Vector.
Parameters
| Name | Type | Description |
|---|---|---|
values | ParserValuesObject | — |
Returns
expand(): VectorMethodExpands a copied Vector, leaving this one unchanged.
Returns
extend(v: ParserEntity): VectorMethodAppends another Vector's element references, mutating this Vector.
core!UnexpectedDataType If v is not a Vector.
Parameters
| Name | Type | Description |
|---|---|---|
v | ParserEntity | Vector whose elements should be appended. |
Returns
Vector — This Vector.
factor(): VectorMethodNo description is available yet.
Returns
forEach(callback: (e: ParserEntity, index: number): void): voidMethodVisits every current element without changing the aggregate. This is the observation-only counterpart to each. Concrete subclasses may narrow the callback element type when their membership method guarantees a more specific entity.
Parameters
| Name | Type | Description |
|---|---|---|
callback | (e: ParserEntity, index: number): void | — |
Returns
void
getExpressionAt(n: number): ExpressionMethodReturns an element after verifying that it is an Expression.
core!UnexpectedDataType If the stored entity is not an Expression.
Parameters
| Name | Type | Description |
|---|---|---|
n | number | Zero-based index. |
Returns
Expression — The stored Expression reference.
gt(V: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
V | ParserEntity | — |
Returns
boolean
gte(V: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
V | ParserEntity | — |
Returns
boolean
indexOf(x: ParserEntity): numberMethodGets the index of the first element structurally equal to x.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to locate. |
Returns
number — The zero-based index, or -1 when absent.
insert(i: number, x: ParserEntity): thisMethodInserts an entity by reference before the provided index.
Parameters
| Name | Type | Description |
|---|---|---|
i | number | Zero-based insertion index. |
x | ParserEntity | Entity to insert. |
Returns
this — This mutated Vector.
integrate(variable?: ExpressionInput): VectorMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
variable | ExpressionInput | — |
Returns
isEnumerable: booleanPropertyNo description is available yet.
isVector(obj: unknown): objMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
obj | unknown | — |
Returns
obj
lt(V: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
V | ParserEntity | — |
Returns
boolean
lte(V: ParserEntity): booleanMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
V | ParserEntity | — |
Returns
boolean
minus(x: NerdamerInput): VectorMethodSubtracts corresponding elements, or broadcasts a scalar subtrahend.
core!DimensionError If a Vector operand has a different length.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
norm(): ExpressionMethodReturns the Euclidean norm sqrt(sum(abs(element)^2)).
core!UnexpectedDataType If any element is not an Expression.
Returns
numeric(precision?: ExpressionInput): VectorMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
precision | ExpressionInput | — |
Returns
plus(x: NerdamerInput): VectorMethodAdds corresponding elements, or broadcasts a scalar addend.
core!DimensionError If a Vector operand has a different length.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
pop(index?: number): ParserEntity | undefinedMethodRemoves an element given an index. If none is provided it removes the last element. Indices are zero-based.
Parameters
| Name | Type | Description |
|---|---|---|
index | number | Optional zero-based index. |
Returns
ParserEntity | undefined — The removed entity, or undefined when no entity is present.
pow(x: NerdamerInput): VectorMethodRaises corresponding elements to powers, or broadcasts a scalar exponent.
core!DimensionError If a Vector exponent has a different length.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
precision: numberPropertyNo description is available yet.
prod(): ExpressionMethodMultiplies all Expression elements in order.
core!UnexpectedDataType If an element is not an Expression.
Returns
Expression — Their product, or one for an empty Vector.
remove(x: ParserEntity): VectorMethodRemoves the first element equal to x, rather than matching by reference.
Parameters
| Name | Type | Description |
|---|---|---|
x | ParserEntity | Value to remove. |
Returns
Vector — This Vector, whether or not a match was found.
reverse(): thisMethodReverses the Vector in place.
Returns
this — This Vector.
simplify(): VectorMethodNo description is available yet.
Returns
sort(compareFn?: (a: ParserEntity, b: ParserEntity): number): thisMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
compareFn | (a: ParserEntity, b: ParserEntity): number | — |
Returns
this
subst(value: ExpressionInput, withValue: ExpressionInput): VectorMethodNo description is available yet.
Parameters
| Name | Type | Description |
|---|---|---|
value | ExpressionInput | — |
withValue | ExpressionInput | — |
Returns
sum(): ExpressionMethodAdds all Expression elements in order.
core!UnexpectedDataType If an element is not an Expression.
Returns
Expression — Their sum, or zero for an empty Vector.
text(): stringMethodNo description is available yet.
Returns
string
times(x: NerdamerInput): VectorMethodMultiplies corresponding Vector elements, broadcasts a scalar factor, or multiplies this Vector from the left of a Matrix.
Vector-to-Vector multiplication is the element-wise (Hadamard) product. Use dot when a scalar inner product is intended. For a Matrix operand, this Vector is interpreted as a row vector. Nonzero-width products reuse the existing Matrix-vector product through the transpose; a compatible zero-width Matrix has the empty Vector as its result because its transpose cannot be represented.
core!DimensionError If Vector dimensions are incompatible.
core!MathError If Matrix dimensions are incompatible.
Parameters
| Name | Type | Description |
|---|---|---|
x | NerdamerInput | — |
Returns
toArray(): ParserEntity[]MethodReturns a new array containing the aggregate's current public element view.
Returns
toPolynomial(vars: string[]): PolynomialMethodInterprets ordered elements as ascending polynomial coefficients.
Parameters
| Name | Type | Description |
|---|---|---|
vars | string[] | — |
Returns
toString(): stringMethodNo description is available yet.
Returns
string
trim(): VectorMethodRemoves every element equal to zero.
Returns
Vector — This mutated Vector.
