Tyl Programming Language
▶ LOOPING STATEMENTS
Looping statement is a statement that has two components: Selector statement can be:
Looping Statement Composition
Say we have a dialer program, and a ring function that tries to call the other side:
ring phone_num »
≡ Here comes the code that tries to ring
≡ the number on the other side of the line.
≡ if successful, return: TRUE, otherwise FALSE.

main »
 phone_num '+999-99-0000000'

 is_ringing ~
  rang_ok ring phone_num
  is_ringing not rang_ok
The line: 'is_ringing ~', is the looping line, and: is_ringing, is the selector statement. The tilde symbol: '~', is Tyl code for looping, and it comes right after the selector statement.
The lines after the looping line are the repeat block. The selector decides if to repeat the execution of the repeat block.

The repeat block can be modified to one statement:
is_ringing ~
 is_ringing not ring phone_num
If there is only one statement in the repeat block, it is possible to write the repeat statement right after the selector:
is_ringing ~ is_ringing not ring phone_num
The line: 'is_ringing ~ is_ringing not ring phone_num', is called a one-line-loop, and is good for short looping statements.


Looping statement structure:

[LOOPING-SELECTOR] ?
 [STATEMENT]     repeat block - statements
 [STATEMENT]     that will be executed
 [STATEMENT]     based on the selector state


PART 2