flowstdlib 1.0.0

The standard library of functions and flows for 'flow' programs
Documentation
flow = "sequence"
docs = "sequence.md"

# The number the sequence should start at
[[input]]
name = "start"
type = "number"

# limit of the sequence - inclusive
[[input]]
name = "limit"
type = "number"

# 'step' is the amount to add each time
[[input]]
name = "step"
type = "number"

# The sequence of numbers we will generate
[[output]]
name = "number"
type = "number"

# the last value is output when the sequence ends (may not be == limit if step is not 1)
[[output]]
name = "last"
type = "number"

# compare_switch will pass all numbers that are less than the limit on the "right-lte" output
[[process]]
source = "lib://flowstdlib/control/compare_switch"

# For the first time around, pass the start number of the sequence into "compare_switch"
[[connection]]
from = "input/start"
to = "compare_switch/right"
name = "first"

[[connection]]
from = "input/limit"
to = "compare_switch/left"
name = "limit"

# connect the right-lte output of compare_switch to the output of this flow - the sequence of numbers being generated
[[connection]]
from = "compare_switch/right-lte"
to = "output/number"

# while the sequence is running - loopback the limit value to compare against next time
[[connection]]
from = "compare_switch/left-gt"
to = "compare_switch/left"
name = "feedback-limit"

# An add process to add "step" to the last output of the sequence each time
[[process]]
source = "lib://flowstdlib/math/add"

[[connection]]
from = "input/step"
to = "add/i2"
name = "step"

# Take generated number of the sequence and pass it to 'add' to add one to it for the next number in the sequence
[[connection]]
from = "compare_switch/right-lt"
to = "add/i1"
name = "previous"

# Feedback step for next iteration
[[connection]]
from = "add/i2"
to = "add/i2"
name = "feedback-step"

# Feed next value back to compare_switch for the next iteration
[[connection]]
from = "add"
to = "compare_switch/right"
name = "feedback-value"

# When compare_switch determines the next value is the last (greater-than-or-equal to the limit) then
# output that value - whose presence indicates it's the end of the sequence
[[connection]]
from = "compare_switch/right-gte"
to = "output/last"