Skip to content
This repository has been archived by the owner on Jan 1, 2019. It is now read-only.

Commit

Permalink
add lolcat folder with basic documentation and a few sample codes
Browse files Browse the repository at this point in the history
  • Loading branch information
zandraaperjesi committed Oct 7, 2017
1 parent caf0923 commit ca52d12
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
93 changes: 93 additions & 0 deletions LOLCODE/LOLCODEBasics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# LOLCODE :smile_cat:

LOLCODE is an esoteric programming language with its keywords based on the lolcat internet meme. This language was created by Adam Lindsay in 2007.
This is just a short introduction to the language, but if you would like to dig deeper into how to LOLCODE, there is a good documentation on [github](https://github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md) .
## Basic structure

The code looks as following:
- HAI [VERSION] -- First line defines what version of LOLCODE the code was written in
- [BUSINESS LOGIC] -- Your code
- KTHXBYE -- Last line, terminates the code

Example hello world code
```
HAI 1.2
VISIBLE "hello world!"
KTHXBYE
```
## Variables

* YARN (string)
* NUMBR (integer)
* NUMBAR (floats)
* TROOF (bollean)
* NOOB (untyped)

LOLCODE's typing is dynamic. Variables with no value assigned are NOOB.
You can cast variables. E.g: casting a YARN yarn to NUMBR would look like:
```
...
yarn IS NOW A NUMBR
...
```

### YARN

YARNs can be written between double quotation marks ("this is a yarn").
In LOLCODE ":" is the escape character, therefore can be used for YARN manipulation.
* :) represents a newline (\n)
* :> represents a tab (\t)
* :o represents a bell (beep) (\g)
* :" represents a literal double quote (")
* :: represents a single literal colon (:)

### Math

The basic math operators are binary prefix operators.
```
SUM OF <x> AN <y> BTW +
DIFF OF <x> AN <y> BTW -
PRODUKT OF <x> AN <y> BTW *
QUOSHUNT OF <x> AN <y> BTW /
MOD OF <x> AN <y> BTW modulo
BIGGR OF <x> AN <y> BTW max
SMALLR OF <x> AN <y> BTW min
```

### If

```
<expression>
O RLY?
YA RLY
<code block>
[MEBBE <expression>
<code block>
[MEBBE <expression>
<code block>
...]]
[NO WAI
<code block>]
OIC
```

If the expression is WIN the code block in YA RLY will run (if), if not then it is checked against the MEBBE (else if) expressions in order if one of them is WIN, its block will run. If none of the expressions evaluated WIN the NO WAI (else) code block will run.

### Loops

LOLCODE loops start with IM IN YR LOOP and end with IM OUTTA YR LOOP. Infinite loops must have a GTFO break. You can use UPPIN for incrementing the variable by one and NERFIN for decrementing the variable by one. The loop with TIL runs as long as the expression evaluates FAIL, loop with WILE runs as long as expression evaluates WIN.

```
IM IN YR <label> <operation> YR <variable> [TIL|WILE <expression>]
<code block>
IM OUTTA YR <label>
```


### Resources

* [LOLCODE](http://lolcode.org/)
* [github documentation](https://github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md)
* [online coding environment](https://repl.it/languages/lolcode) for trying out code
* [esolangs](https://esolangs.org/wiki/LOLCODE#Loops) wiki page for LOLCODE
* [Brainfuck Interpreter](https://esolangs.org/wiki/User:999eagle/Brainfuck_Interpreter) by 999eagle on esolangs
5 changes: 5 additions & 0 deletions LOLCODE/basicLoop.lol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
HAI 1.2
I HAS A VAR ITZ 0
IM IN YR LP UPPIN YR VAR TIL BOTH SAEM VAR AN 5
VISIBLE SUM OF VAR AN 1
IM OUTTA YR LP
3 changes: 3 additions & 0 deletions LOLCODE/helloworld.lol
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HAI 1.2
VISIBLE "HELLO WORLD!"
KTHXBYE
15 changes: 15 additions & 0 deletions LOLCODE/likeCats.lol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
HAI 1.2
BTW asks you if you like cats
I HAS A answer
VISIBLE "do u like cats? [y/n]"
GIMMEH answer
BOTH SAEM answer AN "y"
O RLY?
YA RLY
VISIBLE "meow"
MEBBE BOTH SAEM answer AN "n"
VISIBLE "gtfo pls"
NO WAI
VISIBLE "ths is a [y/n] question"
OIC
KTHXBYE
12 changes: 12 additions & 0 deletions LOLCODE/smaller.lol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HAI 1.2
BTW returns the samller of two numbers
I HAS A x
I HAS A y
VISIBLE "gimmeh a numbr pls"
GIMMEH x
VISIBLE "gimmeh anothr numbr pls"
GIMMEH y
x IS NOW A NUMBR
y IS NOW A NUMBR
VISIBLE SMALLR OF x AN y " is smallr"
KTHXBYE

0 comments on commit ca52d12

Please sign in to comment.