## _no_value, SINK, split & multiple input/output

### _no_value and _multiple_values

You can output *_no_value *or* _multiple_values *to indicate that no value should be appended to an output stream or that multiple values should be appended. For example if you extend a stream by the list [1, *_no_value*, 2] then the stream is extended by [1, 2], and *_no_value *is **not** appended to the stream. Note that streams can contain elements with the value None; for example, if you extend a stream by the list [1, None, 2] then the stream would be extended by [1, None, 2].

You can extend a stream by *_multiple_values*(*v*)* *where v is a list in which case each element of v is appended to the stream. If you extend a stream by [[0, 1, 2], [3, 4, 5, 6]] then the contents of the stream will be extended by two elements: the list [0, 1, 2] and the list [3, 4, 5, 6]. If, however, you extend a stream by [*_multiple_values*(* *[0, 1, 2]), *_multiple_values *([3, 4, 5, 6])] then the contents of the stream will be extended by a single list [0, 1, 2, 3, 4, 5, 6].

### Split, Multi, Sink Decorators

You can write applications using only *map* and *merge*; however, for convenience *IoTPy* also has a *split* decorator for single input and multiple outputs, the *multi* decorator for multiple inputs and multiple outputs, and *sink* for a single input and no outputs. These decorators can also use state and keyword parameters, but they don’t have a functional form. Since they are so similar to map and merge, you will be able to use them after looking at an example.

## split: Single input multiple outputs

@split_e def h(v): return [v*2, v+10] h(in_stream=x, out_streams=[y,z]) # y[n] = x[n]*2 # z[n] = x[n]+10 @split_w def f(window): return [sum(window), max(window)] f(in_stream-x, out_streams=[y,z], window_size=3, step_size=2) # y[n] = sum(x[2*n: 2*n+3]) # z[n] = max(x[2*n: 2*n+3])

For the special case of splitting a stream into exactly two streams you can also use a functional form as in the following examples.

@fsplit_2e def h(v): return [v*2, v+1000] y, z = h(x) @fsplit_2w def h(window): return [sum(window), max(window)] y, z = h(x, window_size=3, step_size=2)

Click here to download examples of split or download examples from GitHub at I*oTPy/examples/split/examples_split.py.*

The examples of *multi* are similar to *split*; the difference is the input to *multi* is a list of streams and not a single stream.

## MUlti: Multiple input and output streams

@multi_e def f(a_list): return max(a_list), sum(a_list) f(in_streams=[w,x], out_streams=[y,z]) # y[n] = max(w[n], x[n]) # z[n] = sum(w[n], x[n]) @multi_w def f(windows): return( sum(sum(window) for window in windows), max(max(window) for window in windows)) f(in_streams=[w,x], out_streams=[y,z], window_size=2, step_size=2)

Click here to download examples of multi or download examples from GitHub at *IoTPy/examples/multi/examples_multi.py.*

## sink

Sink has a single input and no outputs. It can be used with state and keyword arguments. It is exactly like the other decorators used to convert a conventional function into a function operating on streams.

In the following example, calling the decorated function *pr*(*x*) prints the elements of the stream *x, *with one element per line.

@sink_e def pr(v): print (v) pr(x)

Click here to download a file of examples of sink, or download examples from GitHub at *IoTPy/examplese/sink/examples_sink.py*