Icon

Exercise 1

<p><strong>Chapter 8/Exercise 1</strong></p><p>In this exercise, we implement a CASE Switch block within a loop.</p><p>We first generate numbers from 1 to 10 with the <em>Table Creator</em> node. We then process the numbers, however, we want process the numbers differently: Multiply even numbers by 3 (top branch) and odd numbers by 10 (bottom branch).</p><p>To identify whether a number is even or odd we implement a modulo operation using the <em>Expression </em>node. We then process the data row by row using a <em>Table Row to Variable Loop Start</em> node. To process the even and odd numbers accordingly, we implement a CASE Switch block inside the loop, activating either the top port if the number is even, or the bottom port if the number is odd. The <em>Loop End</em> node collects the results of each iteration.</p>

Workflow: Chapter 8/Exercise 1


In this exercise, we implement a CASE Switch block within a loop.

We first generate numbers from 1 to 10 with the Table Creator node. We then process the numbers, however, we want process the numbers differently: Multiply even numbers by 3 (top branch) and odd numbers by 10 (bottom branch).

To identify whether a number is even or odd we implement a modulo operation using the Expression node. We then process the data row by row using a Table Row to Variable Loop Start node. To process the even and odd numbers accordingly, we implement a CASE Switch block inside the loop, activating either the top port if the number is even, or the bottom port if the number is odd. The Loop End node collects the results of each iteration.

Creating input data

Loop body

CASE Switch

Case 1 (port 0): Number is even

Multiply by 3

Case 2 (port 1): Number is odd

Multiply by 10

Collect results ofthe different branches
CASE Switch End
Collect results forall iterations
Loop End
Loop overlist of numbers
Table Row to Variable Loop Start
Active port controlledby flow variable "Rest"
CASE Switch Start
Expression
Expression
Identify if number iseven (0) or odd (1)
Expression
Numbers from 1 to 10
Table Creator
Filter tocurrent number
Row Filter

Nodes

Extensions

Links