LOLCODE
Elegant? Nope. Efficient? Definitely not. Beautiful? Well, you know what they say: beauty is in the eye of the beholder.
HAI
I HAS A kitty ITZ 1
IM IN YR house UPPIN YR kitty TIL BOTH SAEM kitty AN 101100
BTW, computin yr mods
I HAS A d00d ITZ NOT MOD OF kitty AN 3
I HAS A doge ITZ NOT MOD OF kitty AN 4
I HAS A bro ITZ NOT MOD OF kitty AN 5
ANY OF d00d bro doge MKAY, O RLY?
YA RLY
d00d, O RLY?
YA RLY
VISIBLE "Fizz"!
OIC
doge, O RLY?
YA RLY
VISIBLE "Jazz"! BTW, wow such jazz
OIC
bro, O RLY?
YA RLY
VISIBLE "Buzz"!
OIC
NO WAI
VISIBLE kitty!
OIC
VISIBLE ""
IM OUTTA YR house
KTHXBYE
Some explanation:
LOLCODE programs begin with HAI
and end with KTHXBYE
.
Variables are dynamically typed and are assigned using I HAS A <variable> ITZ <value>
. Once defined, variables can also be assigned using <variable> R <value>
.
Loops in LOLCODE are named. The syntax is:
IM IN YR <loop> UPPIN YR <index> TIL BOTH SAEM <index> AN <end>
<stuff to do>
IM OUTTA YR <loop>
This is just Internet speak for "loop until i = end". In LOLCODE 1.2, the indexing variable needs to be initialized prior to the loop. Here the loop is named "house" because it makes reading the loop initialization sound humorous.
VISIBLE
prints to stdout. By default a newline is appended, but adding !
suppresses the newline.
Conditionals are specified as follows:
<condition>, O RLY?
YA RLY
<code to execute if condition is true>
NO WAI
<code to execute if condition is false>
OIC
Conditions must either be expressions which evaluate to a boolean or boolean values. In LOLCODE, the boolean type is called TROOF
and it has values WIN
(true) and FAIL
(false).
Single-line comments begin with BTW
.
Not well-versed in the language of teh Internetz? Just let me know and I'll happily provide further explanation.