I've just been playing around with LolCode again. As I was experimenting, I found that I was confused about how I could make an array which I could iterate over. I also realized that I don't know how to do something like this:

- Code: Select all
`int a;`

int b[];

//...

b[a] = 1;

Is this part of the planned 1.3 spec? Or has this already been implemented and I'm just missing it?

I've done some cursory research and I've found some arbitrary online specs at http://lolcode-ctools.googlecode.com/svn/doc/spec/lolcode-v1.0-rec.txt which talk about something like this:

- Code: Select all
`I HAS A array ITZ A BUKKIT`

I HAS A offset ITZ 1

offset IN MAH array R 5 BTW array[offset] = array[1] = 5

Of course, I think this spec is relatively incompatible with how things seem to be working in lci, so I'm not certain if this is the way to go. Otherwise, I haven't been able to find any good examples of what I'm looking for.

Thanks!

Edit:

So, naturally, after I made this post, I found some stuff on the mailing list that I hadn't tried. Specifically stuff using SRS. So I wrote a quick test and made sure it works. Of course, if there's a better way to do this, I'm open to suggestions.

Here's some example code I wrote up to test that everything works:

- Code: Select all
`HAI 1.3`

BTW Generates Fibonacci numbers into an array

BTW Obviously, it could be more efficient, but I wrote it to test out arrays.

I HAS A number

I HAS A array ITZ A BUKKIT

GIMMEH number

number R MAEK number A NUMBR

IM IN YR loop UPPIN YR index TIL BOTH SAEM index AN number

BOTH SAEM index AN SMALLR OF index AN 1

O RLY?

YA RLY

array HAS A SRS index ITZ 1

NO WAI

array HAS A SRS index ITZ SUM OF array'Z SRS DIFF OF index AN 1 AN array'Z SRS DIFF OF index AN 2

OIC

IM OUTTA YR loop

IM IN YR printLoop UPPIN YR index TIL BOTH SAEM index AN number

VISIBLE array'Z SRS index

IM OUTTA YR printLoop

KTHXBYE