by Minh Le
Version 3 (June 10, 2024)
Download (40 downloads)
This is an example showing how to use flows in a pseudo-function fashion. It requires two other flows: the "Function Scanner" and "Run() function". Before running this flow, make sure to run the setup flow in "Function Scanner". Additionally, you can see the steps if you disable logging.
Update: Changed explanations and switched to payloads from arrays to dictionaries
This flow contains two functions that can be used outside of it:
@Example mathStuff(api, numbers, odds, showSteps = 0)
/** Does random on number pairs in an array, merging it into a single number */
@ExampleOutside(statement=72) executeOp(api, numbers, operation, randIndex, returnTo, showSteps = 0) => numbers, infinity
/** Executes single step and returns the modified numbers array and whether a division by zero occurred */
For the purpose of this tutorial, imagine that the executeOp() function exists in a separate flow. More information on formatting the description for the API scan can be found in Part 1. Additional information is provided in message dialogs within this flow.
You may notice that having a single flow is much faster (10x or more, especially if inside a loop) than calling other flows because it uses a single constant fiber. Nevertheless, sometimes, it might be better to create a separate re-usable function to break down tasks instead of copying and pasting blocks.