ID:168439
 
If I have a list like so:

L[2][2]

It will be like this won't it?

L[1] = L[1][1] L[1][2]
L[2] = L[2][1] L[2][2]

My question is, does that mean there are 6 things in my list or just 4?

Also, how do you write to an association?

I couldn't do this:

L[1][2] = src.icon

It would add a list into L[1][2] rather than an icon. The list inside L[1][2] will have an icon though.
I don't think it works that way in BYOND. What you want is a hashtable, and I don't know whether anybody has written a hashtable system for BYOND.
proc/fake_hash()
ASSERT(args.len)
var/list/fakehash = new
for(var/i=1,i<=args.len,++i)
var/list/l = args[i]
for(var/j=1,j<=l.len,++j)
fakehash["[i],[j]"] = l[j]
return fakehash
Is that the sort of thing you're thinking of?
DeathAwaitsU wrote:
If I have a list like so:

L[2][2]

It will be like this won't it?

L[1] = L[1][1] L[1][2]
L[2] = L[2][1] L[2][2]

My question is, does that mean there are 6 things in my list or just 4?

Astute observation. Technically, there are two things in the list L, which are other lists. Each of those has 2 values.

Also, how do you write to an association?

I couldn't do this:

L[1][2] = src.icon

It would add a list into L[1][2] rather than an icon. The list inside L[1][2] will have an icon though.

L[1][2]=icon will definitely put an icon in that spot, but if you wanted to write to an association, you'd need an value to associate it with, not the position in the list. I.e., L[1]["red"]=icon will do.

Lummox JR
In response to PirateHead
PirateHead wrote:
I don't think it works that way in BYOND. What you want is a hashtable, and I don't know whether anybody has written a hashtable system for BYOND.

Dan and Tom did; it's called associative lists. While technically it doesn't use hashes the principle is the same.

Lummox JR