Vektor Flow

A compact mathematical language for working with values, dimensions and functions.

Examples · Syntax · Features · Download · Performance

Write the relationships in your data. Named dimensions align values; explicit reductions combine them. Functions work over compatible structures, and demand selects what must be computed.

Examples

Edit and run these examples in your browser. This compiler is incomplete; the examples below are verified.

Named dimensions and reductions

Names align dimensions. Repeating a name selects a diagonal; summation is explicit.

Editable example · Loading compiler…
Console
[3, 7]
[1, 4]

Matrix contraction

Editable example · Loading compiler…
Console
[[19, 22], [43, 50]]

Calls and specialization

Parentheses call a function. Square brackets bind arguments into a callable.

Editable example · Loading compiler…
Console
5

Ordered folds

A fold takes one binary reducer, one indexed value and one initial accumulator.

Editable example · Loading compiler…
Console
6

Function values and composition

Editable example · Loading compiler…
Console
[4, 6]
8

Composition applies add before double.

Exact derivatives

Editable example · Loading compiler…
Console
6

Lazy demand

Editable example · Loading compiler…
Console
0
1
2
3

The consumer selects a finite prefix.

Loop indices

$ is the current value, $i the named coordinate, and $0 the outermost loop's iteration index. Nested loops use $1, $2 and later depths.

Editable example · Loading compiler…
Console
0
0
10
1
1
20

Scalar scopes do not add a loop. Loop indices are read-only and scoped to their loop.

Nominal reconstruction

Editable example · Loading compiler…
Console
2
3

Compatible operations reconstruct through the constructor. Different nominal types do not implicitly unify.

Captured function values

Factories preserve each callable's concrete captures, including owned strings.

Editable example · Loading compiler…
Console
23
A4

Callable selection

Editable example · Loading compiler…
Console
5
6

The index selects a callable before its arguments execute.

Forward function declarations

Editable example · Loading compiler…
Console
5

Declaration planning preserves executable source order.

Complex contractions

Editable example · Loading compiler…
Console
[[58 - 2i, 64 - 2i], [139 - 8i, 154 - 8i]]

Tuples and vector rank

Tuples describe records; square brackets add vector dimensions.

Editable example · Loading compiler…
Console
[(1, 2), (3, 4)]
[[1, 2], [3, 4]]

pairs has rank one; matrix has rank two.

Anonymous and named dimensions

Names align by identity. Anonymous dimensions align positionally with other anonymous dimensions. A suffix names the complete rank; ... explicitly preserves the remaining anonymous dimensions.

Editable example · Loading compiler…
Console
[[1, 2], [3, 4]]
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]

A repeated dimension in an access selects a diagonal. A reduction removes only the dimensions explicitly selected. Mismatched aligned sizes are errors.

Structural calls

A selected dimension enters the function intact; the other dimensions lift.

Editable example · Loading compiler…
Console
[1, 4]

The function receives each column.

Indexing and slicing

Inside .(), : preserves one dimension, ... preserves the remainder and :: inserts a size-one dimension.

Editable example · Loading compiler…
Console
[3, 4]
[1, 3]
[[[1, 2], [3, 4]]]

Concatenation

Editable example · Loading compiler…
Console
[1, 2, 3, 4]

Physical quantities

Units belong to the whole value. Arithmetic checks physical dimensions and converts compatible quantities; addition keeps the left operand's preferred unit.

Editable example · Loading compiler…
Console
2.3 m
230 cm
[100, 200, 300] cm

Unit-aware helpers

Ordinary functions preserve quantity information. Conversion changes display, while storage retains the same physical quantity.

Editable example · Loading compiler…
Console
[100, 200, 300] cm
[1, 2, 3] m

Empty values and demand

An empty computation retains its type and shape, and performs no element work. An explicit whole-value conversion retains its display preference at zero length.

Editable example · Loading compiler…
Console
[] cm
[200, 200] cm

Units and powers

Editable example · Loading compiler…
Console
9 m^2
3 m/s

Angles and complex values

Angles are physically dimensionless, with radians as their canonical magnitude.

Editable example · Loading compiler…
Console
1
-1 + 1.2246467991473532e-16i

Floating-point evaluation retains the small imaginary residue.

Domains and physical dimensions

A numerical domain, physical dimension and display unit carry different information.

Editable example · Loading compiler…
Console
18 m
12 m/s
4 m/s^2

The intended symbolic domains x:R[L] and t:R[T] describe length and time; symbolic domain-variable differentiation is still planned. Function transforms already derive velocity and acceleration from the position function.

Templates

Double quotes interpolate immediately. Single quotes defer interpolation until .format(...). A prefix : spills runtime arguments.

Editable example · Loading compiler…
Console
x = 1.3
[1.3, 2.5]

Binding function arguments

Declare ordinary parameters in parentheses. Square brackets bind named arguments into a callable; parentheses evaluate the remaining arguments.

Editable example · Loading compiler…
Console
8

Ordinary names such as x_min and particle_count remain identifiers; alphabetic suffixes select structural dimensions where applicable.

Geometry and physics

Properties describe meaning; dimensions describe structure. Connected dimensions u, v, w describe curves, surfaces and volumes. c describes components; t describes time. Other letters group values without naming an object category.

Connected geometry

One add call creates one layer. Three coordinate components make this a 3D curve:

Editable example · Loading compiler…
Console

set changes defaults, add creates a layer, push freezes the composed state, append adds and pushes, and plot appends and shows.

Explicit topology

References connect independent groups. The m dimension holds member slots.

Editable example · Loading compiler…
Console

Here i groups vertices and b groups edges; reference values connect them. The group letters themselves have no built-in vertex or edge meaning.

Unit-aware state evolution

A Law is an ordinary function over physical state. For constant acceleration:

Editable example · Loading compiler…
Console
6 m
4 m/s

The same semantics should support compiler-selected CPU or GPU execution without user-written kernels or memory transfers.

Motion fields

One ordinary function advances positions across entity and component dimensions:

Editable example · Loading compiler…
Console
[[0, 2, 0], [1, 4, 0]] m
[[0, 1, 0], [0, 2, 0]] m/s

World integration is incomplete. Its design treats motion without _t as initial state and motion with _t as prescribed state. Prescribed position takes precedence over velocity, then acceleration, then Laws.

Shared geometry, multiple views

Two viewports use the same geometry with different cameras:

Editable example · Loading compiler…
Console

Grouped camera:cameras_a and view:views_a remain intended syntax. The current compiler uses separate viewports; geometry stays independent of the view.

Event and I/O concurrency

Compute scheduling belongs to the compiler. Event and I/O concurrency uses ordinary functions with queues, broadcasts, processes and shared values.

Queue and process

Editable example · Loading compiler…
Console
42

A queue delivers each item to one consumer; get() waits efficiently.

Broadcast and shared values

Editable example · Loading compiler…
Console
ready
ready

Both active subscribers receive ready. shared accepts one ordinary value; published generations are immutable. Its update API remains a separate design decision.

VKF is experimental. These examples define intended behavior; compiler support and target verification are tracked independently.