{ }codelper

Learn with tiles › 31

Repeat for each

Take the values of a list out one by one, from first to last, and do something with each.

1

The repeat for each in a list tile takes the values of a list out one by one, in order, and runs the tiles inside once for each value. The fruits in the slot of the tile decides which list to go through. The value taken out is kept in the variable item. If you tap a slot inside "repeat for each", item appears under Variables in ▾.

Write the values one per line.

To do Make apple, pear, plum appear one per line.

Loading tiles…

2

Console: numbers on a line brings in numbers separated by spaces, like 3 5 8, as a list of numbers.

If you take them out one by one and add each to the variable total, you get the sum of them all.

To do Make the sum of all the numbers on one line appear. For 3 5 8 it is 16.

Loading tiles…

3

If you put "if" inside, you can choose. Let's find the biggest number.

The variable biggest already holds the first number. Take the numbers out one by one. If the number taken out is bigger than biggest, change biggest to that number.

To do Make the biggest of the numbers appear. For 3 9 5 it is 9.

Loading tiles…

Next: Finding and sorting →