FUNCTIONS
HAI
CAN HAS STDIO?
SO IM LIKE RECURZIVE WITH var
	IZ var BIGGER THAN 1?
	YARLY
		NERFZ var!!1
		I HAS A val ITZ RECURZIVE WITH var
		UPZ var!!1
		WOOT var TIMEZ val
	NOWAI
		WOOT 1
	KTHX
KTHX
I HAS A var
GIMMEH var
VISIBLE RECURZIVE WITH var
KTHXBYE
Noobs, read this
SO IM LIKE <name> WITH <parameters>

This sets up the function with a name and a list of parameters separated by space.

I HAS A <name> ITZ <value>

Create a variable and give it a value.

NERFZ <name>!!<value>

Decrease the value of the variable. Default = 1

WOOT <value>

Returns the value.

<value> TIMEZ <value>

Multiplication.

NOWAY

Do this if the test returned false (same as }else{).

<name> WITH <parameters>

Run function name with parameter(s).


Ooh, lots of good stuff here.

Thanks for the contribution! — Adam, 2007/05/28 22:00


Yeah, I'm not sure what I could use instead of woot, but I think nerf is descriptive of decreasing the value.

Also, I could change the function definition to use !! instead of WITH, since its used with UP VAR!!1 and in your caturday example. — Marius, 2007/05/28 22:32

MORPLZ would be a memorable increment keyword. — Bob Cat, 2007/05/28 23:27


A few of my friends and I were laughing about some ideas we had, but then we decided that a bunch of them are fairly good. Here is what we came up with for function syntax (in true lolcat fashion):

HAI
COUNT CAT IZ WATCHING UR MIN, MAX DO
  I HAS A COUNTER IZ MIN
  IM IN YR LOOP
    VISIBLE COUNTER
    IZ COUNTER > MAX
      KTHXBYE
    :(
      UP COUNTER!!1
    KTHX
  IM OUTTA YR LOOP
  I FOUND MAH COUNTER
KTHX

COUNT WITH 1,10
KTHXBYE

Function declaration:

<funcname> CAT IZ WATCHING UR <vars> DO

Return:

I FOUND MAH <return value>

End of Function declaration:

KTHX

All variables are local to the function and no external variables should be visible within the function.

Optionally, a global variable could be accessed by replacing “I HAS A <var> [IZ <value>]” by “I GOT UR <var>”

Kyle, 2007/05/29 04:16


For return keyword, we could use GIEF

GIEF VAR

Marius, 2007/05/29 13:28


I like “I FOUND MAH” for the return, but if we use MAH for an array, that doesn't work. Instead, what about “I FOUND TEH”?

It could look something like:

HAI
  CAN HAS STDIO?
  SO IM LIKE RECURZIVE WITH VAR
      IZ VAR BIGGER THAN 1 O RLY?
          YA RLY
              NERF VAR
              I HAS A VAL ITZ RECURZIVE WITH VAR
              UP YR VAR
              I FOUND TEH VAR TIMEZ VAL
  	  NO WAI
              I FOUND TEH 1
      KTHX
  KTHX
 
  GIMMEH VAR
  VISIBLE RECURZIVE WITH VAR
KTHXBYE

I agree that NERF is synonymous with decreasing a value, given that all the l33t kiddies who play video games complain that XYZ Corp. has NERF'd their game.

GIEF also makes sense as a return keyword. From the same reasoning as above, eg. GIEF GOLD PLZ.

shox, 2007/05/29 17:54


Love this syntax. It's magnificent and reads well.

Question: there are multiple suggestions for if-than-else here…is there a decent page where this is being argued yet?

wohali, 2007/05/30 21:45

I like WOOT for return.

Zombie, 2007/05/31 08:28

Someone else had the GIEF idea as well as me. +1 for GIEF.

Al, 2007/05/31 12:09 BST


My suggestion for handling more than one parameter. Simply space delimiting the parameters wont work, because then what happens if you try to pass the result of one function as the parameter of another:

VISIBLE JOIN tbl1 SPLIT tbl2 3 tbl3

I have used THEN, but if someone has a better suggestion, please come with it.

HAI
CAN HAS STDIO?
SO IM LIKE JOIN WITH var1 THEN var2
	I HAS A new
	I HAS A i
	I HAS A j
	LOL i R 0
	LOL j R 0
	IM IN YR LOOP
		IZ i SMALR THAN length IN var1 ?
		YARLY
			LOL i IN MAH new R i IN MAH var1 
		MEBBEIZ j SMALR length IN var2 ?
			LOL i IN MAH new R j IN MAH var2
		NOWAI
			GTFO
		KTHX
	KTHX
	WOOT new
KTHX

I HAS A bukkhit1
I HAS A bukkhit2
LOL 0 IN MAH bukhit1 R 1
LOL 1 IN MAH bukhit1 R 2
LOL 0 IN MAH bukhit2 R 3
LOL 1 IN MAH bukhit2 R 4
VISIBLE JOIN WITH bukkhit1 THEN bukkhit2
KTHXBYE

Marius, 2007/05/31 13:16