ID:136069
 
This is the way I *think* that BYOND works, I don't feel like taking a break from working on my game (motivation is that scarce) to make sure that I am correct.

If you have a list, and you add a list to it, then it makes it one list.
var/list/somelist = new/list() somelist += list(1,2,3) somelist += list(4,5,6)
That should result in somelist being a list with six elements: 1,2,3,4,5 and 6. However, what if you wanted a list of lists. The way it works, somelist[1] equals 1, what if you wanted somelist[1] to be list(1,2,3)?

I ran into this situation, but I found a workaround that probably works better than using a list of lists like I had originally thought to do.
If I remember right, if you want to add a list L to another list X (and have L retained as a list instead of its items becoming items of X) you can do it with X += list(L). Sounds like you thought of that already, though.
In response to Gughunter
Actually, I didn't. I figured that using datums would work even better. Anyway, I finished the routine that all of that was part of, otherwise I'd consider going back and trying that. Thanks though, I'll keep this in mind.
In response to OneFishDown
You can also do something along the lines of "list[1][1]" to output the first thing on the first list in the list itself, comes in handy if you're trying to access items within a list that is within a list itself.
In response to Gughunter
Gughunter wrote:
If I remember right, if you want to add a list L to another list X (and have L retained as a list instead of its items becoming items of X) you can do it with X += list(L). Sounds like you thought of that already, though.

That shouldn't work; whenever you add a list to another list, BYOND will assume you want to add the items in it. This is how you'd do it:
var/i = mylist.len
mylist += null
mylist[++i] = list(1,2,3)
The trick is, you can get a list of lists by setting a value directly.

You can also use association to do that.
mylist[list(1,2,3)] = null

Lummox JR
In response to Lummox JR
The method Gughunter mentioned does in fact work. Following the + operator the contents of the list will be added to the list, but the contents of the list is a list so the intact list will be appended.
In response to tenkuu
tenkuu wrote:
The method Gughunter mentioned does in fact work. Following the + operator the contents of the list will be added to the list, but the contents of the list is a list so the intact list will be appended.

Ah. I hadn't realized what he was doing exactly. But you're right.

Lummox JR