ID:1603455
 
proc
InsertList(var/list/L1, var/list/L2) // Adds L2 to L1's contents
L1 += 0 // Add a dummy index to L1
L1[L1.len] = L2 // Insert L2 at the 0 recently added to L1
return L1 // L1 has been modified


The return statement isn't really necessary unless you want to set a third list to be equal to the InsertList(A, B) but I left it in there just in case someone wants it.

I recently discovered why my matrix library was making no headway, I needed to override the List.Add() proc (or the += operator for lists). Ter13 said I couldn't override operators, so I came up with this.

This code will insert a list into another list, even if it's empty. This is different from the default behavior of List.Add() and List += because if you add an empty list to an empty list, the resultant list is empty. If you add an empty list to a nonempty list, the resultant list is the nonempty list without any kind of modification. This proc allows you to be a bit more flexible with lists.

This will come as part of my matrix library when it's completed, but stand-alone it's good for any number of games.