In many cases it's shorter to read variable values from STDIN rather than defining a function. However, note that GIMMEH
, which reads input from STDIN, always reads a YARN
(i.e. string). But you can take advantage of LOLCODE's dynamic typing and add 0 to convert to a NUMBR
.
For example,
GIMMEH n
n R SUM OF n AN 0
... (operations on n)
Defining n
is 26 bytes, including newlines. Compare this to a user-defined function:
HOW DUZ I f YR n
... (operations on n)
IF U SAY SO
This requires 28 bytes.
Note that you could also multiply by 1 to convert to a NUMBR
, but that requires 4 more bytes than the sum:
GIMMEH n
n R PRODUKT OF n AN 1
I had thought about posting this myself. It's actually not impossible to golf in LOLCODE. – Alex A. – 2015-05-09T18:39:41.960
2Somewhat embarassingly, my second and third highest upvoted answers are in LOLCODE. So I will take this opportunity to share everything I know. – Alex A. – 2015-05-09T18:51:34.190