Boomerlang

From Esolang
Jump to navigation Jump to search

Boomerlang is an esoteric programming language developed by User:Quito0567 on August 27, 2023. It uses a pointer, referred to as a boomerang, that is constantly moving in a certain direction and executing any lines of code it touches. The boomerang also reverses its direction whenever it reaches the program's top or bottom, resulting in an infinitely repeating program. Note that when the boomerang changes direction, the line # it is currently at is not re-executed.

Commands

  • Toss outputs the following value(s) to the console.
  • "Catch variable from prompt" gets user input with the specified prompt and stores the response in the specified variable.
  • "Throw boomerang x feet direction" causes the boomerang to travel x lines in the specified direction (north = up, south = down). You can also use just throw boomerang to simply reverse the boomerang's direction. This is useful for creating loops. Each time a throw boomerang is executed, the built-in throws variable will be incremented by 1.
  • Catch boomerang terminates the program.
  • Curly braces can contain multiple lines. When the boomerang reaches the first or last line in curly braces, its direction will be reversed.
  • Variables are assigned like in standard Python.

Example programs

Hello, world!

toss "Hello, world!"
catch boomerang

Truth machine

catch input from "Enter 0 or 1: "
if input = 0: {toss 0; catch boomerang}
if input = 1: toss 1

99 bottles of beer

b = 99 {
if throws = 196: {
toss "1 bottle of beer on the wall"; toss "1 bottle of beer."
toss "Take one down, pass it around,"; toss "No bottles of beer on the wall."; catch boomerang
}

toss b, "bottles of beer on the wall,"
toss b, "bottles of beer."
toss "Take one down, pass it around,"
b -= 1
toss b, "bottles of beer on the wall."
toss ""
throw boomerang 11 feet north 
}