HAI CAN HAS STDIO? I HAS A NUMBER!!1!!11 VISIBLE NUMBER KTHXBYE
Outputs 19
Any literal number is represented in binary using 1 as 1 and ! as 0. This applies to any statement that uses literal numbers (e.g. UP).
— Mr Flibble, 2007/05/30 23:27
I had thought that 1 and ! were used somewhat interchangably!!1! It seems counter-intuitive that 1 and ! should have different meanings. Perhaps 1 and/or ! should be the binary 1 while 0 and/or O and/or o should be binary 0?
— Hymie, 2007/05/31 00:10
!!!01!001!! isn't something you've ever seen in a macro, now is it?
1 and ! are used interchangeably elsewhere but that's only because there were no situations in which they'd be treated differently before this.
— Richard Fine, 2007/05/31 01:34
I think using !!!!111!!11 for binary (with ! as a zero) is an excellent idea - it solves one of the problems I have with an original example (COUNT!!5 meaning count += 5) that there is no reason for any other number than 1 to be mixed with bangs.
Plus I really like the idea that lolcats only program in binary.
And how about using that for arrays, too?
I HAS A VAR VAR IZ 1!!!1!1 I HAS A BUKKIT BUKKIT!1 IZ "ONE" BUKKIT!1! IZ "TWO" BUKKIT!11 IZ "THREE"
Thats bukkit[1]=“one”; bukkit[2]=“two”; etc. (always has to start with a ! - which is a zero - to allow for numbers possibly being used in variable names).
— Garoo, 2007/05/31
Don't forget that leading zeros ('!'s) will be dropped, so an expression can also indicate the programmer's enthusiasm. (Unless of course someone can think of an application for them)
i.e. I HAS A NUMBER!!1!!11 and I HAS A NUMBER!!!!!!!!!!!1!!11 are equivalent terms.
— Mr Flibble, 2007/05/31 16:51
My god that would get complicated. I'd really prefer not to have to do binary. — Greg, 2007/05/31 17:08
Just how much LOLCode can you see yourself having to write, Greg?
Nonetheless it would probably be OK to have regular-style numbers as an interchangable alternative. In some places (e.g. MEBBE VAR IZ > 37) a sequence of !!1! would look wrong, and we already have “I HAS A VAR IZ 25” syntax that this could be used as an alternative to. If someone comes up with a nice syntax for array indexing then it'd be fully sorted.
After all, it's all about style…
— Richard Fine, 2007/05/31 17:18
I like the all-binary idea, but I see a few problems to making it look good and functional at the same time. If we allow alphanumeric variable names, then a variable such as VALUE1 would be lost in the fray. I propose that we designate the two characters after the first ! as follows:
I HAS A NUMBER!!!11!1 BTW the !!! mean assignment, so the variable NUMBER gets the value 11!1 = 1101 = 13 I HAS A NUMBER1!!!1!! BTW the !!! still means assignment, so the variable NUMBER1 gets the value 1!! = 100 = 4 NUMBER!!!11!!! BTW the !!! still means assignment, so the variable NUMBER gets the value 11!!! = 11000 = 24 NUMBER!!!!!!!!!1!1 BTW extra ! don't matter since they're just leading zeroes, NUMBER gets the value 1!1 = 101 = 5 NUMBER!!1 BTW !!1 means increment (default of 1) so NUMBER is incremented by 1 NUMBER!!111 BTW !!1 still means increment; NUMBER is incremented by 3 (11) NUMBER!1! BTW !1! means decrement (default of 1) so NUMBER is decremented by 1 NUMBER1!1!1! BTW !1! still means decrement so the variable NUMBER1 is decremented by 2 (1!)
Also, !11 could be used for something else (array indices?).
Another suggestion, for big numbers, how about using ONE as an exponential, as in:
I HAS A NUMBER!!!1!!ONE1!1 BTW this means: NUMBER !!!(assigned to) 1!!ONE1!1 = 1!! e 1!1 = 100 e 101 = 4e5 = 400000
These changes would let us declare, define, and reassign numeric variables with strings consiting entirely of !, 1, and ONE. pretty! ^^
Of course, there's no reason to disable someone using the normal “I HAS A NUMBER ITZ 32” syntax, but for the zealous lolcoder this could be a fun, brainf**k-esque style for writing numbers.
— xrestassuredx, 2007/05/30 18:01
@Richard - I don't have to do any programming actually, I just do it for fun. Hence my Game of Life example. — Greg, 2007/05/31 18:12
I like the idea of inserting a random (but meaningful) (or then, maybe not) ONE in the middle of ones and bangs.
Here's the other problem I have with !!1 being used to increment, though: it's not readable. It seems to me that lolcode has to make some kind of sense when you read it, which it doesn't in that case. And if you look at C and you don't know anything about the language, you'll still figure out that i++ has something to do with adding something somewhere - whereas !!1 is just punctuation, and doesn't make any sense to me as an operator.
And I don't think cats really need an increment operator anyway.
— garoo, 2007/05/31
TBH, the !!1 increment operator was what I picked up from discussions in the discussions about for loops and that sort of thing. From reading there, it does seem that we need an increment operator, and I liked this best by far of all the suggestions made in those comments.
Is ”!!” really that much less readable than ”++” or ”+=” as an operator? It seems that if we're trying to avoid punctuation, the emphatic ”!!!11!!!1!!” style fits the language and gets the job done with regard to your earlier comment, garoo, about the ugly “COUNT!!5”. If we can use similar constructs for assignment, incrementing, decrementing, it might be a little obfuscated, but I think lolcode with ones and bangs everywhere makes it that much more fun.
Just my attempt to kill several birds with only a couple bangs, so to speak.
EDIT: It also works to not have an increment operator per se, but if we can replace ”=” ”+=” and ”-=” with bangs we're doing okay. Maybe VAR!!!1 would mean VAR=1, VAR!!1 means VAR+=1, VAR!1 means VAR-=1, something like that. There's no need for a leading 0 in a binary number, so we can place significance on the number of bangs before the first 1.
Someone else can talk now.
- – xrestassuredx
Poor kittehs have a hard enough time with English, now increment operators? Besides, it's easy enough to use vars if needed.
— Church Tucker, 2007/05/31 23:56