LOLCODE is an esolang (short for esoteric language) made by Adam Lindsay. According to Google, esoteric means "intended for or likely to be understood by only a small number of people with a specialized knowledge or interest." You'll see how that definition is true as we continue.
All LOLCODE programs must start with
HAI 1.2 and end with
KTHXBYE. This is very important to remember!
As usual, we'll be starting with the simplest command.
Here's the code:
VISIBLE "HELLO WORLD"
The VISIBLE function displays text or variables.
In this case, it is displaying the string "HELLO WORLD" which is defined by the quotes surrounding it.
One line comments in LOLCODE use the BTW keyword.
An example is below:
BTW omg this is a comment!
Multiline comments begin with OBTW and end with TLDR.
An example is below:
OBTW wow this iz a multiline comment TLDR
In LOLCODE, variables are declared like so:
I HAS A < variable name > ITZ < value >
Here is an example:
I HAS A VARIABLE ITZ 2
In the example, we declare a variable with the name VARIABLE witha a value of 2. You do not have to specify the data type, and the value of the variable does not need to be assigned right now. It can also be down like so:
I HAS A VARIABLE VARIABLE R 2
Next, we have LOLCODE's different data types.
LOLCODE has 5 different data types.
I HAS A INTEGER ITZ 2 BTW data type is NUMBR I HAS A FLOAT ITZ 1.5 BTW data type is NUMBAR I HAS A STR ITZ "MEOW" BTW data type is YARN I HAS A BOOL ITZ WIN BTW data type is TROOF I HAS A UNTYPED BTW data type is a NOOB
Now, let's take a closer look at each of them.
NUMBR is the LOLCODE version of an integer. It is a number with no floating points (decimals)
I HAS A INTEGER ITZ 2 BTW data type is NUMBR
NUMBAR is a float. It is an integer with a decimal point and numbers beyond it
I HAS A FLOAT ITZ 1.5 BTW data type is NUMBAR
YARN is a string. It is a string of characters and numbers!
I HAS A STR ITZ "MEOW 123" BTW data type is YARN
TROOF is a boolean. It can be either WIN or FAIL, with WIN meaning True and FAIL meaining False
I HAS A BOOL ITZ WIN BTW data type is TROOF
NOOB is the null type or undefined type. It has a value of no value. Make sense?
I HAS A UNTYPED BTW data type is a NOOB
The math in lolcode is written somewhat like Polish Notation. Here are all the different operators!
SUM OF 15 AN 20 BTW 15 + 20 DIFF OF 100 AN 50 BTW 100 - 50 PRODUKT OF 10 AN 20 BTW 10 * 20 QUOSHUNT OF 30 AN 15 BTW 30 / 15 MOD OF 20 AN 2 BTW 20 % 2 BIGGR OF 23 AN 53 BTW max(23, 53) SMALLR OF 53 AN 45 BTW min(53, 45)
Here is a general syntax rule for math :
< operator > OF < x > AN < y >
You can even do nested math like so:
< operator > OF < x > AN < < operator > OF < x > AN < y > > SUM OF 15 AN PRODUKT OF 100 AN BIGGR OF 10 AN 2 BTW the same as 15 + (100 * max(10,2))
But this is where it gets confusing. Doing nested math can make code messy and I would recommend just doing it line by line.
Comparisons in if statements are important to know. Here is are all the different comparisons.
BOTH SAEM "CAT" AN "DOG" BTW WIN if x == y DIFFRINT 732 AN 184 BTW WIN if x != y BOTH SAEM 12 AN BIGGR OF 12 AN 4 BTW x >= y BOTH SAEM 43 AN SMALLR OF 43 AN 56 BTW x <= y DIFFRINT 64 AN SMALLR OF 64 AN 2 BTW x > y DIFFRINT 75 AN BIGGR OF 75 AN 643 BTW x < y
For a general syntax rule that applies to all of them :
< condition > < x > AN < y >
The condition can change.
Just like LOLCODE's math operators are different, its booleans are also different. To thoroughly explain them, lets take a closer look below.
Equal to (==)
BOTH SAEM keyword is the LOLCODE version of ==. The syntax is below
BOTH SAEM < x > AN < y >
If x is equivalent as y, then the statement will return
WIN (which is the same as True) and the code below will be executed. Otherwise, it will return
Not Equal To
Not equal to is just like the equal to part, but just with different keywords.
DIFFRINT < x > AN < y >
If x is not the same as as y the code below will be executed.
Greater Than or Equal To and Less Than Or Equal To
Greater than or equal to:
BOTH SAEM < x > AN BIGGR OF < x > and < y >
Less than or equal to:
BOTH SAEM < x > AN SMALLR OF < x > and < y >
Greater Than and Less Than
Greater than :
DIFFRINT < x > AN BIGGR OF < x > and < y >
DIFFRINT < x > AN SMALLR OF < x > and < y >
Now that we're FINALLY done with booleans, lets make our program interactive. It's done with
GIMMEH keyword. The syntax is below:
I HAS A < var > GIMMEH < var >
On input, the value of the var will be of the data type
YARN (string). So we are going to have to convert the data type of the variable.
I HAS A AGE GIMMEH AGE BTW age is currently a yarn AGE IS NOW A NUMBR
If statements have the general syntax :
< condition >, O RLY? YA RLY < code here (if condition is true) > MEBBE < other condition > < code here (if other condition is true) > NO WAI < code here (if none of the conditions are true) > OIC
The first condition and the other condition in the example above are comparisons (like
BOTH SAEM and
But what is the
OIC? Well, the
OIC is just there to tell LOLCODE that that is where the If statement ends.
Back to the point. That variable up there is a placeholder for #333. Or any color for that matter. Change it once up there, and it changes it everywhere in the document. You should now have a fairly basic concept of variables now. They don't get much harder than that.
Oh yeah Geometry Dash, comments are made like this:
// Single line
/* Multiline */
As it turns out, unimaginable SEO content ought to dependably be the length of crucial for address all important solicitations a client may have regarding the individual pursue term.
Here the coding updates are quite wise and there should be the people who looking for the stuff about that is pretty tremendous. I’m sure the students able to grab on https://topcvwritersuk.com/cvwritings-couk-review/ further material keep posting such help always. Your blog posts are recommending continue to share more.