Suppose I have a string that takes the form "## ##"
in stdin
that I want to read in, e.g. "15 16"
. That's simple enough:
I HAS A STRINGY
GIMMEH STRINGY
That grabs the whole line from stdin
and stores it into the string—er, excuse me, YARN—called STRINGY
.
How would I go about extracting the two integers in the string? I want to be able to store 15 and 16 each as an integer (LULZ I MEANS NUMBR).
Short answer:
You can't do this in LOLCODE 1.2.
Long answer:
As there are no
YARN
manipulation functions and no way to cast aYARN
to something like aBUKKIT
in the proposed 1.3 specification (whereupon which we could simulate a string as aBUKKIT
of characters), it's not possible to extract numbers from a string like that.Using just the 1.2 spec, we can still make this work, I guess...
Since string concatenation already exists in 1.2 as
SMOOSH ... MKAY
, you could, in theory, reserve variablesstr01
throughstr99
, and then...Next, getting the NUMBRs...
And lastly, what ever you wanted to do with them.
For
...
, fill in the remaining statements that make use of thestr##
variables.If you're gonna use this, I recommend using something to generate the LOLCODE for you, writing this by hand is just not feasible. Especially if you have to support longer input lines like 255 or 1024 characters.