Difference between revisions of "Category:LSL List"
Line 2: | Line 2: | ||
{{LSL Header}}{{LSLC|}}{{LSLC|Types}} | {{LSL Header}}{{LSLC|}}{{LSLC|Types}} | ||
A list is a special kind of data type which can contain zero or more elements | A list is a special kind of data type which can contain zero or more elements. | ||
Lists are signified by square brackets surrounding their elements, which are separated by commas. | Lists are signified by square brackets surrounding their elements, which are separated by commas. | ||
Note that not all elements in the list | |||
List examples: | List examples: | ||
<pre>[0,1,2,3,4], ["Yes","No","Perhaps"], [1,14.154,"Isn't this fun?",<0,0,0>]</pre> | <pre>[0,1,2,3,4], ["Yes","No","Perhaps"], [1,14.154,"Isn't this fun?",<0,0,0>]</pre> | ||
A list can grow dynamically as large as needed during execution, and is only limited by the amount of memory that script has available. However, there is a 72 element limit to lists defined at compile time. | A list can grow dynamically as large as needed during execution, and is only limited by the amount of memory that script has available. However, there is a 72 element limit to lists defined at compile (aka save) time (e.g. lists that you hardcode choices for right in the script.) Such long, predefined lists are common when you are, say, offering the user a plethora of colour choices. | ||
Tip! If you really need 72 more such choices pre-defined in a list just make 2 (or more lists) that don't upset the compiler, and join them together in state_entry() or wherever appropriate: | |||
biggerlist = biglist01 + biglist02; | |||
Lists cannot be nested, this means that a list may not contain another list. | Lists cannot be nested, this means that a list may not contain another list. |
Revision as of 08:43, 13 July 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
A list is a special kind of data type which can contain zero or more elements.
Lists are signified by square brackets surrounding their elements, which are separated by commas.
Note that not all elements in the list
List examples:
[0,1,2,3,4], ["Yes","No","Perhaps"], [1,14.154,"Isn't this fun?",<0,0,0>]
A list can grow dynamically as large as needed during execution, and is only limited by the amount of memory that script has available. However, there is a 72 element limit to lists defined at compile (aka save) time (e.g. lists that you hardcode choices for right in the script.) Such long, predefined lists are common when you are, say, offering the user a plethora of colour choices.
Tip! If you really need 72 more such choices pre-defined in a list just make 2 (or more lists) that don't upset the compiler, and join them together in state_entry() or wherever appropriate:
biggerlist = biglist01 + biglist02;
Lists cannot be nested, this means that a list may not contain another list.
[1, "one", 2, "two"] + [3, "three"] returns [1, "one", 2, "two", 3, "three"] not [1, "one", 2, "two", [3, "three"]]
It is important to note that indexing starts at 0, not 1.
To access the individual elements use the llList2<type> functions.
Extended List Operations
These functions have been created and contributed by LSL users to perform operations not covered by built-in LSL functions.
function | purpose |
---|---|
ListItemDelete | Removes one element from a list. |
ListStridedUpdate | Updates part of a strided list. |
ListToWholeNumbers | Given a list of floats, converts them all to whole numbers (aka integers.) |
ListXorY | Join two lists to make one new combined list, while also eliminating any resulting duplicates in the new list. |
ListXandY | This function examines two lists, and returns a new list composed of the elements that both lists have in common. |
ListXnotY | Show what x list has that y list is missing. |
ListXxorY | Returns a new list, composed of elements that were in either original script, but not both. Note: This is not the same as getting rid duplicates by preserving just one of each duplicated item. It goes further, and removes both items. |
ListXequY | Answers the question: is list X identical to list Y? |
ListXneqY | Answers the question: is list X different from list Y? |
Replace | Replaces a single occurrence of something in a list with something else that you specify. |
Replace All | Replaces all occurrences of 'from list' with those in 'to list' in 'src list'. Not as concise as the replace function above, but will handle multiple items at the same time. |
ListUnique | Given a list of elements, returns a list of only the unique individual elements in that list. |
Subcategories
This category has the following 5 subcategories, out of 5 total.
Pages in category "LSL List"
The following 31 pages are in this category, out of 31 total.