Ex. 1: For loopΒΆ

In this example, you will learn how to use the Loop node to loop over a range of values (from 0 to 9) and evaluate the function:

\(y = x^2\)

First, add a Loop node to the sheet. Make the node large by clicking and dragging the resize handle in the bottom right corner so we can fit node inside. Create two Tunnel terminals on the left of the node and one on the right. Right-click the top-left terminal and change it to an Indexed terminal. Do the same with the terminal on the right. Your sheet should now look like this:

../_images/ex1_loop.png

Next, add a math.Power node inside the Loop node. Connect the top-left Tunnel terminal to the base terminal on the Power node and the bottom-left Tunnel terminal to the exponent terminal of the Power node. Finally, connect the result of the Power node to the right Tunnel node.

../_images/ex1_power.png

Now that all the connections inside the loop are complete, add Range and Float nodes to the left of the Loop node. Connect the range terminal on the Range node to the top-left Tunnel terminal on the Loop node. Connect the Float terminal to the bottom-left Tunnel terminal on the Loop node. Change the value of the Float node from 0 to 2.

../_images/ex1_range.png

Finally, to show the results of the loop, add a Plot node to the right of the Loop node. Connect the right Tunnel terminal on the Loop node to the y terminal on the Plot node. Run the sheet by pressing the play button.

../_images/ex1_complete.png