Loop
What is Loop Node?
A Loop node executes repetitive tasks that depend on previous iteration results until exit conditions are met or the maximum loop count is reached.
Loop vs. Iteration
Type | Dependencies | Use Cases |
---|---|---|
Loop | Each iteration depends on previous results | Recursive operations, optimization problems |
Iteration | Iterations execute independently | Batch processing, parallel data handling |
Configuration
Parameter | Description | Example |
---|---|---|
Loop Termination Condition | Expression that determines when to exit the loop | x < 50 , error_rate < 0.01 |
Maximum Loop Count | Upper limit on iterations to prevent infinite loops | 10, 100, 1000 |
Usage Example
Goal: Generate random numbers (1-100) until a value below 50 appears.
Steps:
-
Use
node
to generate a random number between 1-100. -
Use
if
to evaluate the number:-
If < 50: Output
done
and terminate loop. -
If ≥ 50: Continue loop and generate another random number.
-
-
Set the exit criterion to random_number < 50.
-
Loop ends when a number below 50 appears.
Planned Enhancements
Future releases will include:
-
Loop variables: Store and reference values across iterations for improved state management and conditional logic.
-
break
node: Terminate loops from within the execution path, enabling more sophisticated control flow patterns.
Was this page helpful?