viernes, 20 de septiembre de 2013

Creando una matriz

Tutorial 2: Creating an array What is an array? An array is a set of values (more than 1 variable), in some programming languages, arrays are used to store strings (like C++ for example), Thyme has strings stored in single variables, so arrays don't handle it like that, in a few languages, arrays require their size to be declared, in Thyme, arrays do not require their size to be declared, or even their type (in C++ for example, the underlined parts would be removed if transferred into Thyme: array Arr1 [4] = ["B","A","M",/0"];) How would I go about creating an array? 1.Bring down the console by pressing F11 2.Type a name for your array, it can be anything, like, Pink or Yellow, or Zing or Towel 3.Type an equal sign (=) 4.Start a square bracket ([) 5.Think of some numbers to put in, like, 7,9,2,5 or 1.7, 2.9, 6.6, 4.4 6.Input the values separated by commas, like 7,2,8,"A" 7.End your square brackets (]) 8.Check that you haven't made any mistakes, it should look something like: Zing = [7,2,8,"A"] 9.Press Enter NOTE: if you are putting an array in code, it is advisable to include a semi-colon at the end (;). I heard arrays had to be homogeneous (all of the same data type), is this true? Lists do not have to be homogeneous (in Thyme), but it can be a good idea, depending on what you are doing. Why would I want to use an array? Arrays can be useful for organizing variables into a useful section, also, they can be used in execution orders, to switch to the next step, without much problem I can't get into my array, help? You can access certain areas of your array by typing the address of the element (the specific number), for example, arr = [1.0,1.1,1.2], if I wanted to go to the third one I'd type arr 2 and press enter, if I wanted the first one, I'd type arr 0 and press enter.

No hay comentarios:

Publicar un comentario