May 22nd 2025: A large number of spam user accounts have been removed from the wiki. If your account was accidentally deleted during this process, please get in contact to have it restored!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guide:aya_yaya:array_levidre [2022/09/20 06:38] – fix link ulde3guide:aya_yaya:array_levidre [2023/12/04 05:54] (current) – Add self-link to stop this from showing as an orphan ulde3
Line 1: Line 1:
-======Arrays (Levidre)====== +#REDIRECT guide:array
-<WRAP right> +
-^  Arrays  ^^ +
-^Type|Guide| +
-^Category|AYA/YAYA| +
-^Author(s)|[[dev:Levidre]]| +
-^Published|Unknown| +
-/*^Last updated||*/ /*Uncomment if you update your guide, and add the date it was last updated*/ +
-/*|  Edits & additions welcome  ||*/ /*Uncomment if you want anyone to be able to change/make additions to your guide*/ +
-</WRAP>+
  
- +<wrap hide>[[guide:aya_yaya:array_levidre]]</wrap>
-An array is like a table. It has lines and elements. We can access the lines/elements with an index. +
- +
-The arrays are the only variables needing to be initialized before having a value affected. They are initialized by 'array = IARRAY' +
- +
-A simple array would be anarray = ("Hello","World") : +
-<code>anarray = IARRAY +
-anarray[0] = "Hello" +
-anarray[1] = "World"</code> +
- +
-So here is an array of two elements, it is initialized and then the two elements are added. In the 'anarray[0]', the 0 is the index of the element. The index starts to 0 so anarray[0] is the first element. The other way to put the two elements inside it after having initialized it would be writing **anarray = ("Hello","World")**. +
- +
-If the number of elements inside the array is unknown, a new element can be added by **anarray = (anarray,"a new element")** or shortly **anarray ,= "a new element"**. The element will be added at the end of the array. But an element can be added to the beginning by **anarray = ("the new element",anarray)** +
- +
-The foreach [[guide:aya_yaya:loop (Levidre)|loops]] can be used to check all the elements in an arrays. +
- +
-=====One dimension arrays===== +
-There are two types of arrays with one dimension but all the array with two dimensions are the same. +
-====The string arrays==== +
-A big string with ',' inside it can be considered as an array and the different elements can be accessed with an index. So **anarray = "Hello,World"** is an array with the first element "Hello" and the second element "World"+
- +
-This type of array doesn't need to be initialized. However all the elements inside it must be a chain of character. It can be used as a normal array though when modifying or adding an element, this element must be a chain of character otherwise it won't work. Foreach [[guide:aya_yaya:loop (Levidre)|loops]] cannot work for this kind of array either. +
- +
-====The "normal" arrays==== +
-They need to be initialized and are the ("Hello","World") kind arrays. The elements inside it can be of any kind, it doesn't matter. Though putting an array in an array would mess up stuffs. Foreach [[guide:aya_yaya:loop (Levidre)|loops]] work for them. +
- +
-=====Two dimensions arrays===== +
-They are a mix between normal and string arrays. They are a normal array which elements are strings or string arrays. They are harder to handle. Foreach loops would work only for one dimension, the "normal" one. +
- +
-A two dimension array looks like this : +
-<code> +
-anarray = IARRAY +
-anarray[0] = "Hello,World" +
-anarray[1] = "I,feel,good" +
-</code> +
- +
-It can be written : +
-<code> +
-anarray = IARRAY +
-anarray = ("Hello,World","I,feel,good"+
-</code> +
-To access an element, anarray[index1][index2] would be used. So here anarray[0][1] would be "World"+
- +
-But the way of modifying the elements inside the strings of the array is different. To modify it, the string must be taken, modified, and then put back into the array : +
-<code>anarray = IARRAY +
-anarray = ("Hello,World","I,feel,good"+
-astring = anarray[0] +
-astring[1] = "User" +
-anarray[0] = astring</code> +
-The first line of the array is now "Hello,User"+
- +
- +
-Arrays are very useful to stock data and to do some complicated stuffs.+