LOLCODE MADE EZZZZZ 🙀 😻 😹
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!
ILL BE COVERIN:
- WUT LOLCODE IZ
- STARTING A PROGRAM
- DATA TYPEZ
- FOR LOOPZ
- WHILE LOOPZ
- SMALL PROGRAMS
- HELPFUL LINKZ
- BAI BAI
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.
First of all, to begin a program, we need to start it off with
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.
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
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
BTWstands 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
Nothing, as they are only comments.
We can also have comments on several lines using
OBTWstands for "Oh, by the way".
TLDRstands 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
In LOLCODE, there are 5 main types:
- Strings (A sequence of characters. Eg:
- Integers (A number. Eg:
- Floats (Composed of strings and numbers. Eg:
- Booleans (Binary types, either True or False. Eg:
- 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 =
- Floats =
- Booleans =
WINand False =
- Arrays =
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 -->
:> --> A colon with a closing angle bracket -->
:o --> A colon with a 'o' -->
:" −-> A colon with a double quote --> literal double quote
:: −-> A colon with another colon --> literal colon
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
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:
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 Ameans "I have a"
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:
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].
ITZmeans "It is".
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
NUMBR) to a
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
HAI 1.2 I HAS A name ITZ "Danny" VISIBLE name I HAS A age ITZ 101 VISIBLE age KTHXBYE
To give variables a new value, we use
Let's change the variable
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
Concatenation means joining two things together. For example, the concatenation of "snow" and "ball" makes "snowball".
We can concatenate easily in LOLCODE by using
MKAY, and seperating the different arguments with
SMOOSHmeans "to press together",
MKAYmeans "Hum ok", 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
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
VISIBLE, we wrote
SMOOSH, seperated of all those with
AN, and added
MKAY at the end.
Input is used to collect stuff from the user. In LOLCODE, we use
GIMMEH as the keyword for input.
GIMMEHmeans "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
What's your favourite color? pink You're favourite color is pink! Mine is blue!
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)
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]
BIGGR OF [number1] AN [number2]
SMALLR OF [number1] AN [number2]
And replace the variables
[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
12 8 20 5 0 10 2
Comparisons are used to, well, compare things.
Here is the list of comparisons:
>=Bigger or equal to
<=Smaller or equal to
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
[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
FAIL WIN FAIL
20 are not the same, then
20 are different, then
15 >= 20 isn't correct, then
We will use these comparisons later in conditionals, which is next!
Conditionals are used to control your program flow, meaning you can decide what happens in specific cases.
In LOLCODE the keywords are
O RLYmeans "Oh, really?",
YA RLYmeans "Yes, really",
NO WAImeans "No, why?", and
OICmeans "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
The numbers 10 and 10 are the same.
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 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
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
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?means "What the f**k?",
OMGmeans "Oh my god",
GTFOmeans "Get the f*k out",
OMGWTFmeans "Oh my god what the f*k", and
OICmeans "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
Enter 1st number 800 Enter 2nd number 200 Ohhhhh 1000!!!
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,
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
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
Then there's the
OMGWTF which is the final one, and the code in the loop will only execute if the other
OMGs arn't "validated". And finally, there's the
OIC to finish the loop.
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
IM IN YRmeans "I'm in your",
UPPING YRmeans "Making [iterator variable] bigger",
NERFIN YRmeans "Nerfing your (reducing) [iterator variable]",
TILmeans "Till", and
IM OUTTA YRmeans "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
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
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 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
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.
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 Imeans "How am I",
YRmeans "Your", and
IF U SAY SOmeans "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
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
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 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
O NOES, and
AWSUM THXmeans "Awesome thanks",
O NOESmeans "Oh no", and
KTHXmeans "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. =/
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.
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
'Z. An example:
HAS A= "Has a",
ITZ= "It is",
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
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
You can also have arrays containing a mix of strings (
YARN), integers (
NUMBR), and floats (
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
20 duck 3.14
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
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 (
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 (
Then, we have 3
MEBBEs (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).
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
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
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.
Online LOLCODE IDE: https://www.jdoodle.com/execute-lolcode-online/
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!)
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
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
If anybody read all 5580 words (yes, counted it) within 10 minutes, I would actually be surprised.
HAI 2:02 PM
I HAS A STRING ITZ A YARN
STRING R "DIS IS AWESOME"
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"
@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
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)
I HAS A user_input ITZ A NUMBR
VISIBLE "What do you want to count down from?"
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
Seriously, THANK YOU