N-Dimensional arrays
Lets say you're making a physics simulation with 100,000 objects. For every object you're going to have to have to account for every velocity, acceleration and position.
Using tables for this would easily lead to verbose code and messy for loops.
Numluau solves using N-Dimensional arrays which allow you to apply the same operation over every item inside it.
creating N-Dimensional arrays¶
the easiest way is to create a array is by using a table.
Arrays simplify operations that would be otherwise tedious using regular tables. Removing the need for long for loops and table allocations.
Arrays can also take in nested tables, to represent higher dimensional arrays
restrictions to arrays¶
there are restrictions when making a array
- all items must have the same data type
- the shape of the array must be retangular not jagged
- once created, you cannot change the size of an array
0d arrays¶
While you can make arrays 2d, 3d, 4d etc. you can also create 0d arrays. These arrays represent a single value.
To retrieve the value from this array you can use :Item().
properties of Arrays¶
- dtype - The data type of the items of the array.
- ndim - The dimension of the array.
- shape - A table that determins the dimensions of the array.
- strides - A table that describes how to index the array.
- buffer - The raw table that holds the data.
- offset - Determines the first item of the array.