Temporary stuff.

FUNCTION: STREAM, STREAM -> STREAM
We often need to merge exactly two streams, and to deal with this frequent use case we use the  decorator illustrated in the following code which sets z[j] = 2*x[j] + 3*y[j].

@merge_2_e
f(x, y): return 2*x + 3*y
z = f(x, y)
SPLIT
FUNCTION:  STREAM -> LIST OF STREAMS
Split functions are functions that split a single stream into multiple streams. The split operation requires you to specify the number of output streams into which the input stream is split.

Let g be a function that always returns a list of k values and let z be a stream. The following code creates a list, y, of k streams. Let g_i be the i-th value returned by g and let y_i be the i-th stream in y. The code makes

y_i[n] = g_i(z[n])
@split_e
def h(v): return g(v)
y = h(z, num_out_streams=k)
For example, the following code creates streams x and y, and sets x[n] = 2*z[n], and sets y[n]=z[n]+3.

@split_e
def h(v): return 2*v, 3+v
x, y = h(z, num_out_streams=2)
The special case of splitting a stream into two streams is common; so we use a decorator for that case which doesn’t require specifying the number of output streams. The following example is equivalent to the previous one.

@split_2_e
def h(v): return 2*v, 3+v
x, y = h(z)

SPLIT

function: stream -> list of streams

Split functions are functions that split a single stream into multiple streams. The split operation requires you to specify the number of output streams into which the input stream is split.

Let g be a function that always returns a list of k values and let z be a stream. The following code creates a list, y, of k streams. Let g_i be the i-th value returned by g and let y_i be the i-th stream in y. The code makes

y_i[n] = g_i(z[n])

SPLIT

function: stream -> list of streams

Split functions are functions that split a single stream into multiple streams. The split operation requires you to specify the number of output streams into which the input stream is split.

Let g be a function that always returns a list of k values and let z be a stream. The following code creates a list, y, of k streams. Let g_i be the i-th value returned by g and let y_i be the i-th stream in y. The code makes

y_i[n] = g_i(z[n])