Lists

Lists are a way to conveniently store species on the stack. A list species is at its core, an ordered container of other species. Lists are able to hold any species imaginable, and do not prevent practitioners from mixing the types of species present in an individual list.

List From N

A, B, C, numlist
Reads the number at the head and creates a list of matching length from species on the capsum. The list is ordered such that species added to the capsum earlier are further ahead on the returned list.
eg. A, B, C, 3 → list of A, B and C, in that order

Append

list, Alist
Adds the species at the head to the end of the list below the head. If given a list at the head, that list is added to the end of the list below the head, preserving order in both lists.

Prepend

list, Alist
Adds the species at the head to the start of the list below the head. If given a list at the head, that list is added at the front of the list below the head, preserving order in both lists.

Consolidate

listlist
Removes all null elements from a list. Useful for cleaning data a practitioner does not know to be fully composed of valid values.

Split Head

listlist, A
Pops a list, removes the element at the head, then pushes the resulting list and the element removed from the front of that list, in that order (the species removed from the list is at the head).

Get Index

list, numA
Returns the element at the position of the list specified by the number at the head.

Set Index

list, A, numlist
Replaces the element on the list at the position specified by the number at the head with the species below the head.
eg. list, A, 2 → list with 2nd element replaced by A

Split At

list, numlist, list
Splits a list by the number at the head. Returns a list with the elements up to the given number (the ‘left’ side), and a list with the elements after place denoted by the number (the ‘right’ side).
eg. list, 2 → list of first 2 elements, list of the remaining elements

Insert At

list, A, numlist
Adds a given element at the place on a list specified by the number at the head. Does not delete existing elements, simply shifts them by a place.
eg. list, A, 3 → list with A at the 3rd place, where the original third place is now at the 4th place

Remove At

list, numlist
Pops a list, removes the element at the place specified by the number, and then returns the resulting list. Does not leave a null value behind.
eg. list, 3 → list without its 3rd element

Sublist

list, num, numlist
Pops a list, selects the elements starting from the number below the head and ending at the number at the head.
eg. list, 1, 4 → list of elements starting at the 1st element and ending at the 3rd element

List Length

list|strnum
Pops a list off the capsum and returns the number of elements it contains. Offers the same functionality for strings.