Cind language documentation
Vector is a finite ordered set of objects.
Notation of vector is a list of elements inside brackets ( ... ),
separated by a comma characters.
(It can be imagine, that each element of the vector is a coordinate from a different space,
or it is just another append value to some result.)
(1,,3) // missed element means "null", so it is: (1,null,3)
A vector of 1 element is treated as the one element, that it contains.
(x) // x
(x,y) // (x,y)
(2+2)*2 // 8
(((1+(2)),(4))) // (3,4)
(x).hello(()) // x.hello()
(x,y)++ // (x++,y++)
Therefore, brackets ( ... ) can be freely used to separate language expressions,
until there is no comma inside
(because otherwise it will be a vector of more then one element).
And also, vector itself can be handled as an object:
var x = (a,b); // x is a vector of 2 elements
When a vector is created, it is always converted to linear form,
that is, when some elements are also vectors, then the main vector will be created from its elements
(in other words, the vectors will be separated into elements).
(()) --> ()
(1,(2,3),4) --> (1,2,3,4) // second parameter is a vector, so will take its elements
(1,(),2) --> (1,2) // adding elements of empty vector, will just remove it
(1,,2) --> (1,null,2) // keeping null, because it is not a vector
Notice that arrays, unlike vectors, are not being converted to linear form,
and they keeps order of elements and subarrays (see Arrays).
Once created vector cannot be changed. There are no methods for changing elements of vectors.
Only reading is possible through methods of vector object (see below).
Operators applied on vectors will be applied to its coordinates (elements),
and the result will be a vector of results from coordinates.
(a,b) + (c,d) --> (a+c,b+d)
(a,b) + c --> (a+c,b+null)
a + (b,c) --> a+b
Operator + in above examples can be changed to any other operator
Methods accepted by the vector object:
||length of vector
||returns element at given position
||returns new subvector starting at given position
||returns new array containing elements from the vector
||iteration - sequential function call for each element in the vector
||vector of results
Examples of use:
(x,y).length() // = 2, length of vector
(a,b,c).get(2) // = c, getting element at position 2
(1,2,3,4).subVector(1,2) // = (2,3), creating subvector, staring at position 1, of length 2
(z,t).toArray() // = [z,t], creating array of vector's elements