List: Difference between revisions

m
Link orphaned article
(Created the page (separated from the List Element page))
 
m (Link orphaned article)
Line 5: Line 5:
Every value in a list is assigned an index.
Every value in a list is assigned an index.
This value can then be retrieved from a list by providing its index.
This value can then be retrieved from a list by providing its index.


To store a value in a list, connect the variable you want to store the list at, and an index at which to store the value to a [[List Element]], then attach the output of List Element and a value to be stored to [[Set Reference]].
To store a value in a list, connect the variable you want to store the list at, and an index at which to store the value to a [[List Element]], then attach the output of List Element and a value to be stored to [[Set Reference]].
Line 15: Line 14:
{{Image|List example2.png}}
{{Image|List example2.png}}


== Notes ==


== Notes ==
* The index ranges from 0 to 1,048,575, attempting to access a list at a higher index will result in a "List too big!" error. Negative indices return the default value, and cannot be overwritten.
* The index ranges from 0 to 1,048,575, attempting to access a list at a higher index will result in a "List too big!" error. Negative indices return the default value, and cannot be overwritten.
* Every variable can be treated as a list or a scalar (non-list). When a variable is accessed as a scalar, it points to its value at index 0.
* Every variable can be treated as a list or a scalar (non-list). When a variable is accessed as a scalar, it points to its value at index 0.
* A non-integer index number is rounded down to the next smallest integer.
* A non-integer index number is rounded down to an integer.
* '''For experienced users:''' Plugging the Element output to the Variable of another List Element will add their indexes. This is similar to pointer arithmetic in languages like C. See the image below:
* '''For experienced users:''' Plugging the Element output to the Variable of another List Element will add their indexes. This is similar to pointer arithmetic in languages like C. See the image below:
: {{Image|List Element example1.jpg|Index addition.}}
: {{Image|List Element example1.jpg|Index addition.}}
A problem that commonly arises is the creation of [[2D lists]].


== Example ==
== Example ==