Bored

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

Bored is an in-development esolang created when User:VilgotanL was bored, thus some features and decisions may be questionable.

The only datatype is list. Integers are represented as the length of the list, which makes integers nonnegative. Strings are represented as a list of ascii values as integers.

There are no scopes except the global scope. In the global scope there are variables and functions. A function can have the same name as a variable because functions can only be used by making a function definition or calling them.

History

The esolang was created using a "compiler generator" by the creator, which is a PEG parser generator where the output is code instead of an AST (Abstract Syntax Tree).

Syntax

Statements

To be documented.

Expressions

To be documented.

Standard Functions

Function Description
num2str(n) Converts an integer to a string
geti(list, i) Gets index i of list with indices starting at 0
seti(list, i, value) Sets index i of list to value with indices starting at 0

Examples

Cat program

# inPut is kind of like a keyword and not a function, and it prompts the user for a line of input and returns it as a string
# printLn has the L capitalized and inPut has the P capitalized because i'm bored
printLn inPut

Hello World

printLn "Hello, world!"

Quine

s=[93,10,112,114,105,110,116,32,34,115,61,91,34,32,106,111,105,110,32,110,117,109,50,115,116,114,40,103,101,116,105,40,115,44,32,48,41,41,10,105,61,49,10,119,104,105,108,101,40,105,32,60,32,115,41,32,123,10,32,32,32,32,112,114,105,110,116,32,34,44,34,32,106,111,105,110,32,110,117,109,50,115,116,114,40,103,101,116,105,40,115,44,32,105,41,41,10,32,32,32,32,105,32,61,32,105,32,43,32,49,10,125,10,112,114,105,110,116,32,115]
print "s=[" join num2str(geti(s, 0))
i=1
while(i < s) {
    print "," join num2str(geti(s, i))
    i = i + 1
}
print s

Truth-machine

i = geti(inPut, 0)
while(i == 49) { print [49] sleep ms 0 }
print [48]

FizzBuzz

i = 1
while(i < 101) {
    if(i % 15 == 0) { printLn "FizzBuzz" }
    if(!(i % 15 == 0) && i % 3 == 0) { printLn "Fizz" }
    if(!(i % 15 == 0) && i % 5 == 0) { printLn "Buzz" }
    if(!(i % 3 == 0 || i % 5 == 0)) { printLn num2str(i) }
    i = i + 1
}

99 Bottles of Beer

i = 99
while(!(i < 3)) {
    printLn num2str(i) join " bottles of beer on the wall,
" join num2str(i) join " bottles of beer.
Take one down, pass it around,
" join num2str(i-1) join " bottles of beer on the wall.
"
    i = i - 1
}

print "2 bottles of beer on the wall,
2 bottles of beer.
Take one down, pass it around,
1 bottle of beer on the wall.

1 bottle of beer on the wall,
1 bottle of beer.
Take one down, pass it around,
No bottles of beer on the wall."

Implementation

https://vilgotanl.github.io/Esolang-implementations/js/bored/index.html