I have pretty simple function to apply to inputStream and get outputStream. I was very positive I could accomplish this using flux language, but it turns out getting the previous value in the stream might be a showstopper. Here is the function pseudo-code:
step = (startIntegral - endIntegral) / totalPoints
for(pos = 0; pos < totalPoints, pos++)
{
if (pos == 0)
outputStream[pos] = step * (0.5 * inputStream[pos])
else if (pos == totalPoints - 1)
outputStream[pos] = outputStream[pos - 1] + (step * (0.5 * inputStream[pos]))
else
outputStream[pos] = outputStream[pos - 1] + (step * inputStream[pos])
}
Using the map could have been one option, but how to
- get
outputStream[pos - 1]
? Can I saveoutputStream[pos]
into some temporary variable and then use it? - how to detect first and last points of the stream?