ApasScript.

Data Types

Core types

number

A numeric value. Arithmetic stays exact where possible, including integers, fractions, radicals, and bignums; operations that inherently use numerical approximation can return an approximate number.

boolean

A true/false result -- from a comparison (==, !=, <, <=, >, >=, chains like 0 < x <= 1, and/or/not), or a yes/no function like isPrime() or divides(). Comparisons are exact: sqrt(2) < 1.4143 is decided without rounding. Inside arithmetic a truth value counts as 1 or 0, so sum(xs > 2) counts the elements above 2.

text

Text: "hello", joined with + ("n = " + 3/4 is "n = 3/4", exact), compared with == and <, indexed s[0] and sliced s[1:3] by character. "x = {x}" puts values into text; str/num convert, and split/join/upper/replace work on it (see Strings).

array

An ordered list of numbers -- from a [..] literal, or an array-producing function like divisors()/range()/cumsum().

table

A mutable display table. Create it with table(column...) and append scalar, vector, or matrix cells with addRow(table, value...). Tables render as structured tables in the terminal, browser, and TeX/PDF output.

vector2

A 2D vector, created by vec(x, y). Displayed in physics unit-vector notation ("3i + 4j"), not tuple form.

vector3

A 3D vector, created by vec(x, y, z).

complex

A single complex number a + bi.

complexArray

Several complex numbers together -- the roots solve gives when asked for "complex" ones.

matrix2

A fixed 2x2 matrix, created by mat(...) with two row arrays.

matrix3

A fixed 3x3 matrix, created by mat(...) with three row arrays.

matrixN

A general dynamically sized matrix, including rectangular matrices and square matrices other than 2x2 or 3x3.

symbolic

An unevaluated algebraic expression tree -- what diff()/expand()/factor()/collect() work with and return. A formula: step in .gdsl stays symbolic the same way.

factors

A prime factorization, shown as an actual product (28 -> 2^2 * 7), not a flat list.

point2d

A 2D coordinate-geometry point, created by point(x, y) or returned by point-producing functions like midpoint()/intersect().

line2d

A 2D line in general form ax + by + c = 0, created by line(...)/lineFromPoints()/etc.

circle2d

A circle in centre-radius form, created by circle(centre, r).

ellipse2d

An axis-aligned ellipse (centre, semi-axes rx/ry), created by ellipse(centre, rx, ry).

ratios

3D direction ratios (a, b, c), created by ratios(a, b, c).

function

A user-defined function value (a closure) -- a bare reference to an fn you defined, not a call to it.

record

A structured result from a gtmath function: named fields, e.g. a root's x, residual and status, read with dot syntax (r.x), or an unnamed list of items read by index (g[0]).

map

Keys to values: {"Na": 23, "Cl": 35.5}. Read m["Na"] or m.Na, set m["K"] = 39, loop for (k in m); keys/values/has/delete/len. A bare name as a key is that name as text ({mean: 3}); keys may also be numbers.

Visualization objects

graph

A plotted function/data graph, created by graph() and built up with plot()/scatter()/bar()/title()/etc.

diagram

A drawn geometric-shape diagram (points/vectors/circles/lines), created by draw()/diagram().

network

A graph-theory network (nodes and edges), created by net(n) and built up with edge()/node() -- distinct from the plotting 'graph' type above.

algotrace

A step-by-step recorded run of a graph algorithm, produced by dijkstra() for playback as an animation.

arraytrace

A step-by-step recorded run of a user-written array algorithm (comparisons/writes), produced by trace(arr, fn) for playback as a sort/array visualizer.

flowtrace

A recorded flowchart run of a user-defined function's control flow, produced by trace(fn, args...) for playback as a flowchart animation.

dstruct

A data structure -- linked list, stack, circular queue, hash table (chaining or linear probing), BST/AVL tree, or min/max heap -- built by linkedList()/stack()/queue()/hashTable()/bst()/avl()/minHeap()/maxHeap(). Displays as a picture; operations such as insert()/remove()/search()/push()/pop()/traverse() mutate it in place and return a step-by-step animation.

animtrace

A sequence of diagram frames, one per sampled t, produced by animate(tmin, tmax, n, fn) for playback as a continuous animation.

turtle

A turtle-graphics cursor (position, heading, pen state), created by turtle() and moved with forward()/left()/right()/etc.

webgpu3d

A 3D surface-plot shader scene, produced by surface3d()/surfaceParametric()/curve3d() for rendering in the browser via WebGPU.

surface3d

A CPU-sampled, colormap-colored 3D surface (MATLAB-style), produced by surf()/mesh()/surfc()/contour3() for rendering in the browser via WebGL2. Works in any WebGL2-capable browser, unlike webgpu3d.

image

An author-supplied external image reference, created by image("path.png"[, "caption"[, width]]), for embedding a figure in --tex output.

raster

A picture coloured pixel by pixel, made by canvas(w, h, f). Shows as an image (with a PNG download) and goes into a PDF as a figure.