Try it yourself  ·  Interlace operator

Two clocks.
One stream, nothing lost.

Enter two sequences and the interval between consecutive elements of each (as a rational number, e.g. 2/3, or a decimal, e.g. 0.5). The operator interlaces them into a single combined sequence at the merged interval Δc = Δ1·Δ2 / (Δ1+Δ2).

Δc = Δ1·Δ2 / (Δ1+Δ2)  ·  RQL: FROM core0#core1
How it works

A merge you can always undo

Interlace weaves two regular streams into one, in time order. The combined stream ticks more often than either input, because it has to carry every element of both.

Complete

Every element of both inputs appears exactly once in the result, in the order its tick falls on the timeline. Nothing is dropped or repeated.

Reversible

The combined stream always splits back into the exact two clocks it came from. Merge and split are exact opposites.

Exact

Which input supplies each tick follows a rational Beatty sequence; Fraenkel’s partition theorem guarantees the two sets of positions cover the output exactly, with no overlap.

RQL in practice

The same operator, in a query

In RQL, interlace is written # between two streams. Here core0 ticks every 1/16 and core1 every 1/8, so str3 ticks every 1/24.

query.rql test/IntegrationTest/operations
DECLARE a UINT STREAM core0, 1/16 FILE 'datafile1.txt'
DECLARE a UINT STREAM core1, 1/8 FILE 'datafile2.txt' ONESHOT
SELECT str3[0] STREAM str3 FROM core0#core1

The formal definition and proof are in the paper. The operator algebra is summarized on the home page.