1 | # Functional Programming Library - Explanations
|
2 |
|
3 | ## Transforms
|
4 | ### Neighbors
|
5 |
|
6 | Stream processing may not be an intuitive programming paradigm. Most problems which are addressed only need to work with small data sets where it is possible to iterate over the set to compute an appropriate transformation. With a large data set this is not possible.
|
7 |
|
8 | The neighbors transform is created to produce a traditional bounded context from an (potentially) infinite stream.
|
9 |
|
10 | The transform keeps track of a limited array of data from the stream and presents this along with a specific stream event back into the stream. This makes it simply to use aggregate functions which expect a bounded set of data...such as average or standard deviation.
|
11 |
|
12 | Imagine a stream
|
13 | ```
|
14 | 1
|
15 | 2
|
16 | 3
|
17 | 4
|
18 | 5
|
19 | ...```
|
20 |
|
21 | The neighbors(3) transform produces
|
22 | ```
|
23 | data: 1 neighbors:[1,2,3]
|
24 | data: 2 neighbors:[2,3,4]
|
25 | data: 3 neighbors:[3,4,5]
|
26 | ```
|
27 |
|
28 | You can then use the neighbors array to compare the nth value to its n to n+m neighbors.
|
29 |
|
30 |
|
31 |
|
32 |
|
\ | No newline at end of file |