CamelCase in LOLCODE
Example for versions
loljs 1.1
Note that LOLCODE has no character processing functions, except for concatenation, so you can’t compare characters or get their ASCII-codes. This means that to figure out whether a character is a letter you need to create a “dictionary” of all letters and just look it up.
HAI
I HAS A UPP ITZ "QWERTYUIOPASDFGHJKLZXCVBNM"
I HAS A LOW ITZ "qwertyuiopasdfghjklzxcvbnm"
HOW DUZ I LOWER CHAR
I HAS A I ITZ 0
IM IN YR LOOP UPPIN YR I TIL BOTH SAEM I AN LEN OF UPP
BOTH SAEM UPP!I AN CHAR, O RLY?
YA RLY
FOUND YR LOW!I
OIC
IM OUTTA YR LOOP
FOUND YR CHAR
IF U SAY SO
HOW DUZ I UPPER CHAR
I HAS A I ITZ 0
IM IN YR LOOP UPPIN YR I TIL BOTH SAEM I AN LEN OF UPP
BOTH SAEM LOW!I AN CHAR, O RLY?
YA RLY
FOUND YR UPP!I
OIC
IM OUTTA YR LOOP
FOUND YR CHAR
IF U SAY SO
HOW DUZ I ISLOWER CHAR
I HAS A I ITZ 0
IM IN YR LOOP UPPIN YR I TIL BOTH SAEM I AN LEN OF UPP
BOTH SAEM LOW!I AN CHAR, O RLY?
YA RLY
FOUND YR WIN
OIC
IM OUTTA YR LOOP
FOUND YR FAIL
IF U SAY SO
I HAS A TEXT
GIMMEH TEXT
I HAS A CAMELCASE ITZ ""
I HAS A I ITZ 0
I HAS A SPACE ITZ WIN
IM IN YR LOOP UPPIN YR I TIL BOTH SAEM I AN LEN OF TEXT
I HAS A CHAR ITZ LOWER TEXT!I
ISLOWER CHAR, O RLY?
YA RLY
BTW this is a letter (already lowercase), modify depending on SPACE
SPACE, O RLY?
YA RLY
CHAR R UPPER CHAR
OIC
CAMELCASE R SMOOSH CAMELCASE CHAR
SPACE R FAIL
NO WAI
BTW this is space - mark it
SPACE R WIN
OIC
IM OUTTA YR LOOP
VISIBLE CAMELCASE
KTHXBYE
Comments
]]>blog comments powered by Disqus
]]>