Skiylia-Lang / Verboscript

A toy programming language made in python; designed to be close to written english
GNU General Public License v3.0
2 stars 0 forks source link

Loops #5

Open SK1Y101 opened 3 years ago

SK1Y101 commented 3 years ago

Som syntax ideas for loops:

For loops

Python:

for x in range(10):
    print(x)

This language:

Start a counter at zero, and repeat the following ten times:
    show the counter

While

Python:

while true:
    print(“loops up”)

This language:

repeat the following forever:
    Show loops up

break

Python:

while true:
  if x == true:
    break

This language:

repeat the following forever:
    if the value of x is true, then:
        stop the loop

Not sure whether any of these are readable, but that’s for discussion to decide right?

SK1Y101 commented 3 years ago

The slightly less well known equivalent of while, until instead continues executing while the condition is false:

(modern languages like python and C do not have a direct anaglogue)

while x != 2:
  print(x)

verboscript:

repeat the following until x is equal to two:
  show x.