Tyl Programming Language
▶ ITERATOR
One of the common things in programming is to go over list of items and do operations for each item.

Iterator format:
[LIST] [ITEM] ~
Say we have a list of numbers:
numbers 10 6 16 10
A looping-by-index over them, will look like:
numbers_len len numbers

index numbers_len ~
 num numbers index
print num
10
6
16
10
While it works, it would be better to get each item by looping over the items themselves, and that's the iterator:
numbers num ~
The line: 'numbers num', is the iterator selector. It gets an existing numbers list, and constructs a local variable: num, that will belong to the looping statement, and will hold a copy of an item of numbers, for each iteration.

Printing the numbers:
numbers 10 6 16 10

numbers num ~ print num
10
6
16
10
On first iteration, num gets the first number of numbers: 10, so in the statement: 'print num', it prints: 10. Consequently, the iterator will go over the rest of the numbers and will print them.

What if you try to modify the list item in the iterator statement?
numbers 10 6 16 10
print numbers
numbers num ~ num ++
print numbers
[ 10, 6, 16, 10 ]
[ 10, 6, 16, 10 ]
nums list hasn't changed, because num gets a copy of the current item of numbers, and not the item itself.

Nevertheless, num value inside the iterator repeat block will do change, as can be seen here:
numbers 10 6 16 10

numbers num ~ print num ++
11
7
17
11


PART 2
PART 4