/list proc

/proc/Add(Item1)
Arguments:
Item1

Adds a value, or multiple values, to the list.

var/list/L = list(1, 2)

L.Add(3)
world.log << json_encode(L) // "[1,2,3]"

L.Add(4, 5)
world.log << json_encode(L) // "[1,2,3,4,5]"

If any of the values are another list then the contents of that list will be added rather than the list itself.

var/list/L1 = list(1, 2)
var/list/L2 = list(3, 4)

L1.Add(L2)

// "[1,2,3,4]"
// NOT "[1,2,[3,4]]"
world.log << json_encode(L1)
/proc/Copy(Start, End)
Arguments:
Start = 1: Index of the first element to be included in the copy
End = 0: Index past the last element to be included in the copy, or 0 for the last element
Returns:
A shallow copy of the list

Returns a new shallow copy of the list.

var/list/L1 = list(1, 2, 3)
var/list/L2 = L1.Copy(2)

world.log << json_encode(L2) // "[2,3]"
/proc/Cut(Start, End)
Arguments:
Start = 1: Index of the first element to be cut from the list
End = 0: Index past the last element to be cut from the list, or 0 for the last element

Removes the indicated elements from the list.

var/list/L = list(1, 2, 3, 4)
L.Cut(2, 4)

world.log << json_encode(L) // "[1,4]"
/proc/Find(Elem, Start, End)
Arguments:
Elem
Start = 1: Index of the first element to be included in the search
End = 0: Index past the last element to be included in the search, or 0 for the last element
Returns:
num: The index of the found element, or 0

Search for the given item in the list. If any values in the list are equal, this will return its index. Otherwise it will return 0.

var/list/L = list(10, 20, 30, 20)

// Will return the first instance of 20
world.log << L.Find(20) // 2
/proc/Insert(Index, Item1)
Arguments:
Index
Item1
/proc/Join(Glue, Start, End)
Arguments:
Glue
Start = 1
End = 0
Returns:
text
/proc/New(Size)
Arguments:
Size
Arguments:
Item1
Arguments:
Item1
/proc/Splice(Start, End, Item1)
Arguments:
Start = 1
End = 0
Item1
Returns:
null
/proc/Swap(Index1, Index2)
Arguments:
Index1
Index2