[3] LOLCODE MADE EZZZZZ 🙀 😻 😹
Y HALO THAR EVRYONE!!!
HOPE EVRYONEZ DOIN NICE AN CHILLIN!
WELCOM 2 LOLCODE TUTORIAL!!!
I SET ON TEH PATH 2 LERN LOLCODE. WELL. IT WUZ CERTAINLY REWARDIN EXPERIENCE LULZ.
AS U CAN C, IM SPEAKIN IN ALL CAPS IN DA SACRD LANGUAGE OV TEH LOLCATS! IF U DOAN UNDERSTAND, CHECK DIS TRANZLATOR OUT HER. SAY THE STUFF U DONT COMPREHEND OUT LOUD TO UNDERSTANDZ WAHT THIS MEANZ!
DIS AR TEH GONNA BE VRY ANNOYIN, BUT IZ 2 GIT U USD 2 LOLCODEZ SYNTAX!
OKIE DOKIE LETS START!
(By the way, this is the 3rd tutorial in a series of tutorials I'm making on languages, first one here and second one here)
ILL BE COVERIN:
- WUT LOLCODE IZ
- STARTING A PROGRAM
- OUTPUT
- COMMENTS
- DATA TYPEZ
- VARIABLEZ
- CONCATENASHUN
- INPUT
- OPERATORS
- COMPARISONS
- CONDISHUNALS
- FOR LOOPZ
- WHILE LOOPZ
- FUNCTIONZ
- ARRAYS
- SMALL PROGRAMS
- HELPFUL LINKZ
- SOURCEZ
- BAI BAI
WUT LOLCODE IZ
LOLCODE IZ ESOTORIC PROGRAMMIN LANGAUGE. ESOTORIC MEANZ "intended for or likely to be understood by only a small number of people with a specialized knowledge or interest." (HERE). IT WUZ INSPIRD BY TEH FUNNY LANGAUGE SPOKEN BY LOLCATS (HENCE Y IM SPEAKIN LIEK DIS. FRANKLY, QUITE ANNOYIN, BUT OH WELL). LOLCODE WUZ CREATD IN 2007 BY ADAM LINDSAY, DIS DOOD (I FINKZ, NOT MUTCH IMAGEZ ON TEH INTERNET :/):
AN TEH ICON OV LOLCODE IZ DIS:
BTW DIZ IS A LOLCAT:
Ok now I stop using that annoying language, or else y'all won't understand anything and that'll be sad.
An important thing about LOLCODE is that everything is written in ALL CAPS. Indentation is irrelevant (yay). ALso, it would be great if you already know some languages, it would make learning this language much easier. I totally recommend learning Python first via this amazing tutorial here, or C++ with this super tutorial here! ;) Finally, no syntax highlighting for LOLCODE, so yea much sad.
Oh and also, this tutorial won't only help you learn LOLCODE, it'll also reinforce your programming knowledge and also teach very useful internet slang.
STARTING A PROGRAM
First of all, to begin a program, we need to start it off with HAI 1.2
. 1.2
is basically the version of LOLCODE, and HAI
is just saying "Hi". Then, every program must end with KTHXBYE
, which means "Ok, thanks, bye".
HAI 1.2
KTHXBYE
And in between those two lines, we'll have the program.
OUTPUT
For outputting to the console (the black part), we use the statement VISIBLE
. Here's your first "Hello World!" program in LOLCODE!
HAI 1.2
VISIBLE "Hello World!"
KTHXBYE
Output:
Hello World!
COMMENTS
Comments are very useful in programming as they can make it easier for others to read your code. They can also be used to organize your code and leave notes for yourself. Comments are completly ignored by the compiler, meaning that everything behind or in a comment will not be executed (run) by the program.
In LOLCODE, comments are written with BTW
BTW
stands for "By the way".
HAI 1.2
BTW This is a comment
BTW Another comment!
BTW VISIBLE "HELLO"
BTW that code ^^ won't run!
KTHXBYE
Output:
Nothing, as they are only comments.
We can also have comments on several lines using OBTW
and TLDR
.
OBTW
stands for "Oh, by the way".TLDR
stands for "Too long didn't read".
HAI 1.2
BTW this is a comment
OBTW
This is another comment
On several lines!
Yay!
TLDR
KTHXBYE
DATA TYPEZ
In LOLCODE, there are 5 main types:
- Strings (A sequence of characters. Eg:
"Hello"
) - Integers (A number. Eg:
21
) - Floats (Composed of strings and numbers. Eg:
3.14
) - Booleans (Binary types, either True or False. Eg:
True
) - Arrays (A collection of items. Eg:
[1, 3, 5, 7]
)
But in LOLCODE, they have different names:
- Strings =
YARN
(because yarn is composed of strings lol) - Integers =
NUMBR
- Floats =
NUMBAR
- Booleans =
TROOF
(True =WIN
and False =FAIL
) - Arrays =
BUKKITS
(BUKKIT
= bucket)
In LOLCODE, there are also these smiley faces, kinda like ANSI
escape codes:
Since colons (:
) are used as escape characters in LOLCODE, and any value following a colon makes a specific action:
:)
--> A colon with a closing parenthesis --> \n
:>
--> A colon with a closing angle bracket --> \t
:o
--> A colon with a 'o' --> \g
:"
−-> A colon with a double quote --> literal double quote "
::
−-> A colon with another colon --> literal colon :
Some examples:
HAI 1.2
VISIBLE "Hola:)Ni Hao:)Bonjour:):):)Hello"
VISIBLE ":>Woah:>:>:>Whee!"
VISIBLE ":o:o"
VISIBLE "My name is:: Bookie0"
VISIBLE "That is quite :"disgusting:"!"
KTHXBYE
Output:
Hola
Ni Hao
Bonjour
Hello
Woah Whee!
gg
My name is: Bookie0
That is quite "disgusting"!
As you can see, you can use several of those "smileys" in succession, and you can mix and match them up. The ::
is for just one colon :
, and the :"
is for one double quote "
; if you just put one colon, or just one double quote, or if you omit the colon before like so:
HAI 1.2
VISIBLE "My name is: Bookie0"
KTHXBYE
This will happen:
Line 3: Unrecognized sequence at: "My name is: Bookie0".
Because a single colon :
isn't a valid keyword, you need two of them: ::
.
Or in the second case:
HAI 1.2
VISIBLE "That is quite "disgusting"!"
KTHXBYE
This will happen:
Reference to undefined variable: disgusting.
As it will think disgusting
is a variable, so you need a colon before the double quote: :"
.
VARIABLEZ
Think of variables like boxes that can change values and vary, hence the name. To declare a variable, you use I HAS A [variable]
. Also, when I put [variable]
, you don't have to put that name, and the square braquets are not needed (it was just to represent where to put the variable).
I HAS A
means "I have a"
Example:
HAI 1.2
BTW making a variable called name:
I HAS A name
BTW making a variable called age:
I HAS A age
KTHXBYE
Now that's just declaring the variable. Also, the data type of the variable is handled automatically by LOLCODE. If the variable does not have an initial value, it's declared as untyped, which is NOOB
in LOLCODE.
But you can specify yourself what data type a variable is, using I HAS A [variable] ITZ A [data type]
. But this unforunately doesn't work as well in repl.it, so I tried it in an online LOLCODE IDE and it works.
If you're curious, on repl.it it gives this error:
this.value.codegen is not a function
So as it works perfectly on that IDE, this is probably a problem with repl.it =/
Here is an example of declaring a variable and their data type:
HAI 1.2
I HAS A name ITZ A YARN BTW the variable 'name' is a YARN (string)
I HAS A age ITZ A NUMBR BTW the variable 'age' is a NUMBR (int)
KTHXBYE
A few tips for naming variables (they apply for all programming languages):
Variables are used to hold things, so you should try to name your variables accordingly. For example, you won't name a variable holding an age "bananas" or a variable holding a name "thingy".
Also, try to use camelCase in variables: if you have several words in the variables, join them together and capitalize the 1st letters (except the 1st word). Like the tip above, this is not needed, but just makes your code more readable, and easier for someone to look at your code.
Don't start a variable name with a number.
No spaces or special characters.
No using keywords (eg:
VISIBLE
,BTW
,HAI
) as the names.
If you try to follow those tips, not only will your code run smoothly and without errors, but it will look good and you will be able to read the code faster.
Now to actually assign a value to the variable, we do I HAS A [variable] ITZ [value]
.
ITZ
means "It is".
Some examples:
HAI 1.2
I HAZ A name ITZ "Danny" BTW the compiler will recognize this as a YARN
I HAZ A age ITZ 101 BTW the compiler will recognize this is as NUMBR
I HAZ A food ITZ 3.14 BTW the compiler will recognize this is as NUMBAR
BTW I named it food as 3.14 is pi which is like pie lol
I HAZ A boolean ITZ FAIL BTW the compiler will recognize this as TROOF
KTHXBYE
Once a variable is declared with a data type, you can change it to a different data type, that is called casting.
Casting is when you convert a variable's data type to another data type, for example when you cast a integer
(NUMBR
) to a float
(FLOAT
). You can cast variables with MAEK [variable] A [data type]
(which means "MAKE ... A ..."). This doesn't seem to work on repl.it so I did it on another LOLCODE IDE.
HAI 1.2
I HAS A pie ITZ A NUMBAR BTW declaring a variable called 'pie' that is a NUMBAR (float)
pie R 3.14 BTW storing 3.14 in the variable pie
MAEK pie A YARN BTW casting pie from a NUMBAR to a YARN (string)
KTHXBYE
To output variables, we just do VISIBLE [variable]
:
HAI 1.2
I HAS A name ITZ "Danny"
VISIBLE name
I HAS A age ITZ 101
VISIBLE age
KTHXBYE
Output:
Danny
101
To give variables a new value, we use R
.
R
means "Are".
Let's change the variable age
:
HAI 1.2
I HAS A age ITZ 101
VISIBLE age
age R 102 BTW changing the value of age from 101 to 102
VISIBLE age
KTHXBYE
Output:
101
102
CONCATENASHUN
Concatenation means joining two things together. For example, the concatenation of "snow" and "ball" makes "snowball".
We can concatenate easily in LOLCODE by using SMOOSH
and MKAY
, and seperating the different arguments with AN
.
SMOOSH
means "to press together",MKAY
means "Hum ok", andAN
means "and".
An example of concatenation using the variables from above:
HAI 1.2
I HAS A name ITZ "Danny"
I HAS A age ITZ 101
VISIBLE SMOOSH "My name is " AN name AN " I am " AN age AN " years old." MKAY
KTHXBYE
Output:
My name is Danny I am 101 years old.
As you can see, we joined together the strings "My name is "
and " I am "
and " years old"
, as well as the variables name
and age
. After VISIBLE
, we wrote SMOOSH
, seperated of all those with AN
, and added MKAY
at the end.
INPUT
Input is used to collect stuff from the user. In LOLCODE, we use GIMMEH
as the keyword for input.
GIMMEH
means "Give me".
Let's make a program that asks the user for their favourite color, store it in a variable (so we can use it later), then output what the user said using concatenation:
HAI 1.2
I HAS A favColor BTW making a variable called favColor
VISIBLE "What's your favourite color? "
GIMMEH favColor BTW making an input to ask the user
VISIBLE SMOOSH "You're favourite color is " AN favColor AN "! Mine is blue!" MKAY BTW concatenating what the user said and some other strings
KTHXBYE
Output:
What's your favourite color?
pink
You're favourite color is pink! Mine is blue!
Operators
Operators are basically symbols that can be used in math. Here is the list of operators:
+
For adding numbers-
For subtracting numbers*
For multiplying numbers/
For dividing numbers%
Modulo (for dividing numbers and returning what's left)>
Bigger than<
Smaller than
But in LOLCODE, they have different names:
+
=SUM OF [number1] AN [number2]
-
=DIFF OF [number1] AN [number2]
*
=PRODUKT OF [number1] AN [number2]
/
=QUOSHUNT OF [number1] AN [number2]
%
=MOD OF [number1] AN [number2]
max
=BIGGR OF [number1] AN [number2]
min
=SMALLR OF [number1] AN [number2]
And replace the variables [number1]
and [number2]
with the variables/numbers of your choice (without the square braquets of course lol).
HAI 1.2
BTW the two variables:
I HAS A a ITZ 10
I HAS A b ITZ 2
BTW outputs different operators
VISIBLE SUM OF a AN b
VISIBLE DIFF OF a AN b
VISIBLE PRODUKT OF a AN b
VISIBLE QUOSHUNT OF a AN b
VISIBLE MOD OF a AN b
VISIBLE BIGGR OF a AN b
VISIBLE SMALLR OF a AN b
KTHXBYE
Output:
12
8
20
5
0
10
2
COMPARISONS
Comparisons are used to, well, compare things.
Here is the list of comparisons:
==
Equal to!=
Different then>=
Bigger or equal to<=
Smaller or equal to>
Bigger than<
Smaller than
And of course, in LOLCODE they have different names:
==
=BOTH SAEM [variable1] AN [variable2]
!=
=BOTH DIFFRINT [variable1] AN [variable2]
>=
=BOTH SAEM [variable1] AN BIGGR OF [variable1] AN [variable2]
<=
=BOTH SAEM [variable1] AN SMALLR OF [variable1] AN [variable2]
>
=DIFFRENT [variable1] AN BIGGR OF [variable1] AN [variable2]
<
=DIFFRENT [variable1] AN SMALLR OF [variable1] AN [variable 2]
And replace the variables [variable1]
and [variable2]
with the variables/numbers of your choice (without the square braquets of course lol).
HAI 1.2
BTW the two variables
I HAS A variable1 ITZ 15
I HAS A variable2 ITZ 20
BTW outputs some different comparisons
VISIBLE BOTH SAEM variable1 AN variable2
VISIBLE BOTH DIFFRINT variable1 AN variable2
VISIBLE BOTH SAEM variable1 AN BIGGR OF variable1 AN variable2
KTHXBYE
Output:
FAIL
WIN
FAIL
Because 15
and 20
are not the same, then FAIL
(False).
Because 15
and 20
are different, then WIN
(True).
Because 15 >= 20
isn't correct, then FAIL
(False).
We will use these comparisons later in conditionals, which is next!
CONDISHUNALS
Conditionals are used to control your program flow, meaning you can decide what happens in specific cases.
In LOLCODE the keywords are O RLY
, YA RLY
, NO WAI
, OIC
.
O RLY
means "Oh, really?",YA RLY
means "Yes, really",NO WAI
means "No, why?", andOIC
means "Oh I see!".
Let's make a simple program that determines if two numbers are the same:
HAI 1.2
BOTH SAEM 10 AN 10
O RLY?
YA RLY
VISIBLE "The numbers 10 and 10 are the same."
NO WAI
VISIBLE "The numbers 10 and 10 are the same."
OIC
KTHXBYE
Output:
The numbers 10 and 10 are the same.
Because 10
and 10
are the same numbers.
Now let's break the code down. First we have the expression using the comparisons BOTH SAEM
. This checks if 10
and 10
are the same. Next, we have O RLY
, which kinda acts like the "beginner" of the conditional; you put all the control flow statements inside it. Then I indented the rest of the code. Indents are irrelevant (they don't affect anything), but they make the code look nice.
After, we have YA RLY
, which is like the if
statement. After the YA RLY
, all the code inside it will be executed only if the condition we first mentioned (BOTH SAEM 10 AN 10
) is true, or WIN
. NO WAI
is like the else
statement. If the expression is false, everything after it will be run.
Finally, we have OIC
, which ends the loop. Remember to add it at the end!
We can also add as many MEBBE
statements as we want, they are kinda like elif
statements. Bascially they are the same as YA RLY
, but it's used if there are more condiions.
Taking the example from above, let's add and change some code:
HAI 1.2
I HAS A animal BTW making a variable called animal
VISIBLE "Enter a animal"
GIMMEH animal BTW asking the user to enter a animal
BTW beginning of our conditionals.
BOTH SAEM animal AN "cat"
O RLY?
YA RLY
VISIBLE "Wow catz nice!"
BTW Adding "elif" statements:
MEBBE BOTH SAEM animal AN "dog"
VISIBLE "Wow itz a dogz eh?"
MEBBE BOTH SAEM animal AN "fish"
VISIBLE "Wow fishyyyy!"
NO WAI
VISIBLE "hum other pet?"
OIC
KTHXBYE
Possible output:
Enter a animal
dog
Wow itz a dogz eh?
As you can see, first we have the expression BOTH SAEM animal AN "cat"
, which checks if the animal the user entered is the same as cat
. If yes, (YA RLY
), then it outputs that "Wow catz nice!". Next, we have the first MEBBE
that checks if the user's animal is the same as dog
. If yes, then it outputs a different message. Same thing for the second MEBBE
. Finally, there's the NO WAI
with the messsage "hum other pet?" which will output if any of the above conditions arn't met.
We can also make conditionals based on variable types. We will be using the keywords WTF?
, OMG
, GTFO
, OMGWTF
, and OIC
.
WTF?
means "What the f**k?",OMG
means "Oh my god",GTFO
means "Get the f**k out",OMGWTF
means "Oh my god what the f**k", andOIC
means "Oh I see".
Let's make a program that checks if the sum of two numbers are specific numbers:
HAI 1.2
BTW asks for first number
I HAS A a
VISIBLE "Enter 1st number"
GIMMEH a
BTW asks for second number
I HAS A b
VISIBLE "Enter 2nd number"
GIMMEH b
BTW start of conditionals
SUM OF a AN b BTW this is the expression
WTF?
OMG 10 BTW this will execute if the result of a + b = 10
VISIBLE "Yeaaa 10!!!"
GTFO
OMG 100 BTW this will execute if the result of a + b = 100
VISIBLE "Wooooo 100!!!"
GTFO
OMG 1000 BTW this will execute if the result of a + b = 1000
VISIBLE "Ohhhhh 1000!!!"
GTFO
OMGWTF BTW this will execute if the result of a + b isn't 10 or 100 or 1000
VISIBLE "Not 10 or 100 or 1000?!"
OIC
KTHXBYE
Possible output:
Enter 1st number
800
Enter 2nd number
200
Ohhhhh 1000!!!
Another output:
Enter 1st number
10
Enter 2nd number
3
Not 10 or 100 or 1000?!
Alright, that's a lot of code. So first, we have two variables, a
and b
, and we ask the user to give them values. Next, with SUM OF a AN b
, our expression, we next have the line WTF?
. Next, we first check if that expression equals 10
with OMG
, and if it does, then it outputs a message. After, there's GTFO
, which kinda "breaks the loop" so the rest of the program can continue. Same thing for the other OMG
s.
Then there's the OMGWTF
which is the final one, and the code in the loop will only execute if the other OMG
s arn't "validated". And finally, there's the OIC
to finish the loop.
FOR LOOPZ
You can use loops to repeat certain bits of code for a specific amount of times. Here's the format to make a for loop:
IM IN YR [label/name for loop] UPPIN YR [iterator variable] TIL [expression]
And to end it we use IM OUTTA YR [label/name for loop]
Seems complicated, but once you get the hang of it you'll find it easier! First, we have the [label/name for loop]
which you can call LOOP
as its easier (but you can call it whatever you want, following the rules for making variable names).
Next, we have UPPIN YR [iterator variable]
which is like in a C++
loop the i++
. Bascially, the iterator is kinda like the variable that enables you to through a particular object as many times as you want. It'll become more clear with an example later. Before that, there's UPPIN YR
which is for incrementing, or adding 1 to the iterator. For decreasing the iterator, use NERFIN YR [iterator variable]
.
Finally, we have TIL [expression]
which just makes the loop go on until a specific condition is met.
Then to end the loop, we have IM OUTTA YR [label/name for loop]
, and the label/name is the same as the label/name you first used at the beginning to name you for
loop.
IM IN YR
means "I'm in your",UPPING YR
means "Making [iterator variable] bigger",NERFIN YR
means "Nerfing your (reducing) [iterator variable]",TIL
means "Till", andIM OUTTA YR
means "I'm out of your".
Alright, now an example for the for
loop; let's make a counting program:
HAI 1.2
I HAS A iteratorCount ITZ 0 BTW this is the iteratorCount variable; it will change every time
IM IN YR LOOP UPPIN YR iteratorCount TIL BOTH SAEM iteratorCount AN 11
VISIBLE SMOOSH "We're at " AN iteratorCount MKAY BTW using concatenation
IM OUTTA YR LOOP
KTHXBYE
Output:
We're at 0
We're at 1
We're at 2
We're at 3
We're at 4
We're at 5
We're at 6
We're at 7
We're at 8
We're at 9
We're at 10
So first, we have the variable iteratorCount
that has the initial value of 0
. Then, we have the for loop, which we labeled LOOP
. With UPPIN YR iteratorCount
, we are adding 1
from that variable every loop. After with TIL BOTH SAEM iteratorCount AN 11
, that is the expression, so the code inside will loop until iteratorCount = 11
. Notice that we say 11
and not 10
because if we put 10
, the program would end at We're at 9
, but we want the program to end at 10
. The code inside the loop just outputs "We're at "
then with concatenation we put the iteratorCount
, which like I said above, will decrease every loop.
Remember to add IM OUTTA YR LOOP
at the end to conclude the for loop.
WHILE LOOPZ
While loops in LOLCODE are pretty similar to for loops.
To make a while loop that outputs a message to infinity, you can do something like this:
HAI 1.2
I HAS A ITERATOR ITZ 0
IM IN YR LOOP NERFIN YR ITERATOR WILE DIFFRINT ITERATOR AN 1
VISIBLE "There's no stopping me nowww!"
IM OUTTA YR LOOP
KTHXBYE
Output:
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
There's no stopping me nowww!
...
Maximum call stack size exceeded
Aha! There's a small catch, you can't really make it loop over forever, and, uh to be honest, I don't really know. Also as you can see while loops are kinda the same like for loops, so yea that's why I'm not really talking a lot about them.
FUNCTIONZ
Functions contain blocks of code that you can use as many times as you need/want. For functions in LOLCODE, we'll be using HOW IZ I
to start it and IF U SAY SO
to "close" the function. We'll also use YR
for adding parameters (variables passed onto the function).
Note: parameters are the names of the variables listed in the function, while arguments are the actual values of passed onto the function.
HOW IZ I
means "How am I",YR
means "Your", andIF U SAY SO
means "If you say so".
To declare a function, we do:HOW IZ I [functionName] YR [argument1] AN YR [argument2] AN YR [argument3] etc. MKAY
You can add more parameters, just add AN YR
then the parameter.
So uh, didn't manage how to make it work on repl.it, but you can learn more about functions in LOLCODE, with several examples here. However, I found a LOLCODE online editor (here), and I managed to make it work there.
So let's make a function that where we can put a name and the program greets them with a message:
HAI 1.2
HOW IZ I greeter YR name BTW making a function called greeter with name as an parameter
FOUND YR SMOOSH "Hey there " AN name AN "!" MKAY BTW returns the name to the function, with a message
IF U SAY SO BTW indicates end of function
VISIBLE I IZ greeter YR "dude" MKAY BTW calling the function with different arguments
VISIBLE I IZ greeter YR "bro" MKAY
VISIBLE I IZ greeter YR "man" MKAY
KTHXBYE
Output:
Hey there dude!
Hey there bro!
Hey there man!
So first of all, we call the function with HOW IZ I
then greeter
is the name of the function, you can change it to what you want. Next, the parameters, indicated by YR
. As you can see, I have one parameter; name
, but you can add more if you want, just seperate them with AN YR
.
Next, we return that parameter with FOUND YR
and we use concatenation (SMOOSH ... MKAY
) to output a personalized message to each person. At the end, with IF U SAY SO
, this indicates the end of the function.
Finally, we call the function using I IZ
then then name of the function followed by our arguments, ended with a MKAY
. In the example above, I called the function 3 times, but you can call it more or less than that, each one with a different name. So when the program executes, it will output 3 messages to each of those persons.
EXCEPTION HANDLING
Exception handling is basically adding some code so that if the program encounters some errors, it can keep the program running and not make an error appear in front of the user.
The keywords are PLZ
, AWSUM THX
, O NOES
, and KTHX
.
PLZ
means "Please",AWSUM THX
means "Awesome thanks",O NOES
means "Oh no", andKTHX
means "Ok thanks".
So, hum, didn't get the code to work (sry!!!) on repl.it, so I tried in the LOLCODE IDE I mentioned above, but it doesn't work there, but you can read more about exception handling in LOLCODE here. Tutorialspoint says that:
Please note that as LOLCODE is not maintained regularly, there are no more updates available for LOLCODE exception handling and many other features.
So yea, bummer. =/
ARRAYS
Didn't find much about arrays either because (rly sry!!!), and didn't get it to work on repl.it again, but running it in the online LOLCODE IDE I found, it works yay!
Ok so arrays are basically a bit like variables that contain different items. They are a collection which can be changed and reordered. However, there is a limited amount of things you can do with arrays in LOLCODE. Citing a github tutorial:
Array and dictionary types are currently under-specified. There is general will to unify them, but indexing and definition is still under discussion.
(From here)
So arrays in LOLCODE are called BUKKITS
("buckets"). To declare an array, you use the same expression as declaring a variable. We shall also be using the keywords HAS A
, ITZ
and 'Z
. An example:
HAS A
= "Has a",ITZ
= "It is",'Z
= "'s".
HAI 1.2
I HAS A array ITZ A BUKKIT BTW declaring the array
array HAS A item1 ITZ 20 BTW inserting the variable item1 with the value of 20 in the array
VISIBLE array'Z item1 BTW accessing the variable item1 from the array
KTHXBYE
Output:
20
So first, we declared the array and named it array
(as it seems pretty appropriate) the same way we would declare and name a variable. In the same line, we also assigned it's data type: BUKKIT
. Next, we're adding, or inserting an item inside the array. The item is the variable called item1
with the value of 20
. So when we output an item of our array, item1
, it outputs 20
. This is called accessing.
We can also add more items in our array, like this:
HAI 1.2
I HAS A array ITZ A BUKKIT BTW declaring the array
array HAS A item1 ITZ 20 BTW inserting the variable item1 with the value of 20 in the array
array HAS A item2 ITZ 50 BTW inserting the variable item2 with the value of 50 in the array
array HAS A item3 ITZ 100 BTW inserting the variable item3 with the value of 100 in the array
array HAS A item4 ITZ 1283129837123912038 BTW inserting the varianle item4 with the value of 1283129837123912038 in the array
VISIBLE array'Z item2 BTW accessing the variable item2 from the array
VISIBLE array'Z item4 BTW accessing the variable item4 from the array
KTHXBYE
Output:
50
1283129837123912038
You can also have arrays containing a mix of strings (YARN
), integers (NUMBR
), and floats (NUMBAR
).
HAI 1.2
I HAS A array ITZ A BUKKIT BTW declaring the array
array HAS A item1 ITZ 20 BTW inserting the variable item1 with the value of 20 in the array
array HAS A item2 ITZ "duck" BTW inserting the variable item2 with the value of "duck" in the array
array HAS A item3 ITZ 3.14 BTW inserting the variable item3 with the value of 3.14 in the array
VISIBLE array'Z item1 BTW accessing the variable item1 from the array
VISIBLE array'Z item2 BTW accessing the variable item2 from the array
VISIBLE array'Z item3 BTW accessing the variable item3 from the array
KTHXBYE
Output:
20
duck
3.14
SMALL PROGRAMS
CALCULATOR
Let's make a simple calculator program that can calculate 2 numbers with 4 operators.
HAI 1.2
I HAS A number1 BTW variable for number 1
I HAS A number2 BTW variable for number 2
I HAS A operator BTW variable for operator
VISIBLE "Enter 1st numba pls"
GIMMEH number1 BTW asks for first number
VISIBLE "Enter 2nd numba pls"
GIMMEH number2 BTW asks for second number
VISIBLE "Enter operator (* / + -) pls"
GIMMEH operator BTW asks for operator
BTW beginning of control flow and conditionals
BOTH SAEM operator AN "*" BTW checks if the operator equals the multiplication symbol *
O RLY?
YA RLY
VISIBLE SMOOSH number1 AN " * " AN number2 AN " =" MKAY
VISIBLE PRODUKT OF number1 AN number2
MEBBE BOTH SAEM operator AN "/"
VISIBLE SMOOSH number1 AN " / " AN number2 AN " =" MKAY
VISIBLE QUOSHUNT OF number1 AN number2
MEBBE BOTH SAEM operator AN "+"
VISIBLE SMOOSH number1 AN " + " AN number2 AN " =" MKAY
VISIBLE SUM OF number1 AN number2
MEBBE BOTH SAEM operator AN "-"
VISIBLE SMOOSH number1 AN " - " AN number2 AN " =" MKAY
VISIBLE DIFF OF number1 AN number2
NO WAI
VISIBLE "Oh noes pls enter valid operator smh!"
OIC
KTHXBYE
Possible output:
Enter 1st numba pls
20
Enter 2nd numba pls
50
Enter operator (* / + -) pls
*
20 * 50 =
1000
Or if you do a not valid operator output:
Enter 1st numba pls
10
Enter 2nd numba pls
5
Enter operator (* / + -) pls
idk
Oh noes pls enter valid operator smh!
So a brief explanation of the above code:
First, we have 3 variables; number1
for the first number, number2
for the second number, and operator
for the operator (multiplication, division, addition and subtraction).
Next, we ask the user for those variables with inputs (GIMMEH
).
And now we have the conditionals. Firstly, we have the expression BOTH SAEM operator AN "*"
which checks if what the user entered as an operator equals *
. If it does, (YA RLY
), then it outputs the multiplication of the 2 numbers the user first entered, with concatenation (SMOOSH
, MKAY
).
Then, we have 3 MEBBE
s (kind of like elif
in python or else if
in C++
) which checks if 3 other expressions are correct. In the conditional branches, they each output a different message with concatenation as well as the result of the equation (number1 / number2
, number1 + number2
, and the last one is number1 - number2
).
COUNTDOWN PROGRAM
HAI 1.2
I HAS A count ITZ 15 BTW change '15' to where you want the count to start from
IM IN YR LOOP NERFIN YR count TIL BOTH SAEM count AN -1 BTW for loop
VISIBLE SMOOSH "Count is at " AN count MKAY BTW using concatenation
IM OUTTA YR LOOP BTW ends the loop
KTHXBYE
Output:
Count is at 15
Count is at 14
Count is at 13
Count is at 12
Count is at 11
Count is at 10
Count is at 9
Count is at 8
Count is at 7
Count is at 6
Count is at 5
Count is at 4
Count is at 3
Count is at 2
Count is at 1
Count is at 0
So I would have liked it to use an input (GIMMEH
) to ask the user from where to count start the countdown, but for that I would have to convert (casting) what the user wrote from a default YARN
to NUMBR
so that the for
loop could work, however it didn't work. I tried using another IDE, but it didn't have the expected results.
Anyways explanation of the code: first there's the iterator named count
which has the initial value of 15
. You can change it to what you want. Then, the for
loop loops until count
is equal to -1
. Reminder: we say -1
and not 0
, as if it were 0
, the countdown would end at 1
, but we want it to end at 0
. In the loop, outputs what count we're at using concatenation. Finally, we have IM OUTTA YR LOOP
to "close" the loop.
SOURCEZ
- https://github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md
- https://learnxinyminutes.com/docs/LOLCODE/
- https://www.tutorialspoint.com/lolcode/lolcode_loops.htm
Online LOLCODE IDE: https://www.jdoodle.com/execute-lolcode-online/
BAI BAIII
Aight so that's about all. I had a lot of fun making this tutorial, hope y'all have fun learning this epic language (with this epic tutorial!)
Have a MIAOOOerful (wonderful) day!!!
Btw check out the repl for some of the code, but if you run it it won't work as some parts like functions, arrays, casting don't work on repl.it =/
Yea also this is part of @elipie's Tutorial Jam yay
LOLCODE v1.2 has array support?!
@realTronsi lol yea, but it doesnt work on repl.it =/
@Bookie0 ^;n;^
I love the first language cause' I didn't understand anything...
lol
@PattanAhmed lol :)
@Bookie0 whiskers
@DynamicSquid kittenz
@Bookie0 meowskers
@DynamicSquid whiseows
@Bookie0 el mao zedong
@Bookie0 I HAZ A error ITZ "what in the world did I just read did you have a seizure?"
@CodeLongAndPros lol it's lolcode what'd you expect lol?
@CodeLongAndPros OH NOES! :OVISIBLE "yup had the same reaction when I was browsing the langs on repl.it xD"
:)
¯\_(ツ)_/¯
@DynamicSquid
nice, ill never understand this language its so weird lmao.
lol thanks! :) LOLCODE is indeed a... particular language lol! :D @BobTheTomatoPie
Notice that we say 11 and not 10 because if we put 11, the program would end at We're at 9, but we want the program to end at 10.
Isn't it supposed to say "if we put it at 10"? Great tutorial, though I didn't have to use SMOOSH
@JasonLiu19 ah yes thx :)
@JasonLiu19 It seems that smoosh is treated as an error. It tells me AN is undefined
I was thinking about learning lolcode but then I looked at the scrollbar O_O
lmfao it's not that long
@Chewyblockguy
So hard
But your tutorial is good! @Bookie0
thanks! :D @WilliamXing
Welcome @Bookie0
Wait, I just realised, aren't the Bukkits basically Dictionaries? We're defining their index and assigning values
@Astraisaria lmfao oh yea that's true, didn't even see that. The LOLCODE documentation does say those are arrays tho lol
Fakka drerries!!!!! In the building
@CodeLongAndPros ah yes, thank you! :D
cooooooooooooooooooooooooooooooooooooooooool
thxxxxxxxx :) @ALIMAALIM
If anybody read all 5580 words (yes, counted it) within 10 minutes, I would actually be surprised.
Wow lol I mean to count it you can just use word count on like google docs or something :) @StealthySniper
But yea thanks for reading! :D
@Bookie0 I did use google docs. lol
@StealthySniper cat tut |wc -w
Hey @Bookie0, great job. You put a lot of work into this :)
@RolandJLevy Thank you so much, glad you liked it! :))
@Bookie0 np! :)
@Bookie0 🎈...💥!
@Bookie0 nice! lmao!!
Hey @Bookie0, in my balloon popping game, I just made the cursor use this emoji 📌 https://repl.it/talk/share/GAME-Play-POP-100-a-Totally-Awesome-Game/79626
@RolandJLevy yay cool! maybe add the 💥
bang emoji when you pop a ballon (just a suggestion! ;)
@Bookie0 ah, good idea! I'll give it a try...
yeehaw @RolandJLevy
@Bookie0 thanks for your ideas!
DIS TUTORIAL IZ GREAT! I CAN NAO RITE LOLCODE. 👍
@DannyIsCoding WOHOÔ THX UUU! :)
LOL, NICE!
LOL, THANKS!! :) @JBYT27
LOL, NP! :) @Bookie0
(^‿^) @JBYT27
This is the best LOLCODE tutorial I've ever seen. I think I actually somewhat understand the language now! But I'll have to keep this post open to the side when I code.
@MarcusWeinberger lol yay, happy this helped! :)))))
this language is literally confusion, but the tutorial helped. regice is supposed to be smart
lmfao thanks! :) @ThisUserTaken
lool @tsunami21 what..?
@Bookie0 i think the image explains it enough
@tsunami21 ohhhh just realized you giving an upvote..? but you seem angry to give it lol
@Bookie0 not angry... just intimidated by big brain
ah hum lol thanks! :) @tsunami21
HAI 2:02 PM
I HAS A STRING ITZ A YARN
STRING R "DIS IS AWESOME"
VISIBLE STRING
I HAS A VAR ITZ 0
IM IN YR COMMENT SECTION NERFIN YER VAR TIL BOTH SAEM VAR AND 1 BTW WILL RUN 4EVUR
VISIBLE "LOLCODE IZ AWSUM"
VISIBLE "LOLCATZ R AWSUM"
KTHXBAI
@maxyang LOLCODE IZ VERY AWSUMM!!!
@maxyang i forgot some of my kotlin and english reading this
sadge the jdoodle thing is being slow :<
Y U GIV UP ON TEH LOLCATS LANGUAGE PART WAI THRU
IM DISAPPOINTD IN U @Bookie0
U R DISAPPOINTIN TEH LOLCATS @Bookie0
U R NOT SPEAKIN IN THEIR LANGUAGE, AN IN DA POST U STOPPD LES THAN HALF WAI THRU
@Bookie0
@Codemonkey51 WAZ BC IT WAZ TOO COMPLICATED/HARD AND PEEPS NO UNDERSTANDZ! I DID LINK A VERSION WITH THEIR LANGUAGE: https://repl.it/talk/learn/Btw-if-you-want-to-read-the-tutorial-in/79000/349936
DAT NEEDZ 2 BE IN DA POST AT TEH TOP, NOT IN COMMENT >:( @Bookie0
@Codemonkey51 WOULD BE TOO DIFFICULT TO READ + COMPREHEND!!
ANYONE HOO CAN SPEEK/READ LOLCAT WUD UNDERSTAND @Bookie0
@Codemonkey51 JUST LET IT DROP NVM!! xD
LMAOZ OKE 👍 @Bookie0
@Codemonkey51 LULZ 👌
WANT 2 TAK IN MULTI-PPLZ REPL? CANT DISCRD RGHT NOW. @Bookie0
@Codemonkey51 SRY NOT NAO AM DOIN HW BUT MEBBE TMR! :D
HAI 1.2
OBTW This is my version of the cowntdowner. I guess you weren't able to make the thing overall, but anywhere, here ya go. (Your tutorial taught me the full language in 8 hours)
TLDR
I HAS A user_input ITZ A NUMBR
VISIBLE "What do you want to count down from?"
GIMMEH user_input
MAEK user_input A NUMBR
IM IN YER countdowner NERFIN user_input TIL BOTH SAEM user_input AN 0
VISIBLE "We're at " user_input
IM OUTTA YR countdowner
KTHXBYE
Seriously, THANK YOU
No problem at all, glad this helped!!
@Astraisaria
DIS AR TEH AMAZIN, THANK U VRY MUTCH.
lol thx!! @Astraisaria
I HAS A question
VISIBLE "Why doesnt this have more upvotes?"
LULCODE
@Bookie0 I CAN INVITE U 2 REPL IM HAVIN TROUBLE WIF LOLCODE
@TsunamiOrSumth whats the problemo?
@Bookie0 so uh whats an alternative for
I HAS A thing ITZ A YARN
@TsunamiOrSumth yea thats won't work on repl.it, i dunno why. Try the LOLCODE IDE i mentioned above in the post, somethings not really working on the repl.it LOLCODE IDE =/
@Bookie0 wait but whats an alternative to that, so the program on repl can work
theres no alternative for making a variable a certain data type. =/ it won't work on repl.it, too my furthest knowledge :) @TsunamiOrSumth
@Bookie0 darn. also nice pfp
thanks!! :D @TsunamiOrSumth
the lolcat speak at the start was obnoxious
@AJDevelopment (taht did uoy erehw trap eht nI) .ekortsadahi/r gnidaer ekil tlef tI .niaga taht od reve t'nod ,esaelP
Unreversed: Please, don't ever do that again. It felt like reading r/ihadastroke. (In the part you did that)
@AJDevelopment lool I have the whole tutorial in LOLCAT speak
@AJDevelopment ¯/_)ツ(_\¯
@Bookie0 somehow reversing ¯/_)ツ(_\¯
worked
@AJDevelopment hehe yes
you welcome thxxxxxxxx
I have tears in my eyes, such a beautiful tutorial. GG @Bookie0, this is really good xD.
@RayhanADev lmfao thank you so much for your tears! :DDDDD
@Bookie0 😹
@RayhanADev 😸
@Bookie0 😻
@RayhanADev ¬‿¬
@Bookie0 (°▽°)
@RayhanADev
(*^‿^*)
@Bookie0 ٩( ᐛ )و
@RayhanADev
¯\_(ツ)_/¯
@Bookie0 ƪ(˘⌣˘)ʃ
@RayhanADev 〤◕‿◕〤