a Scilab object and a list definition function
list(a1, ..., an)
Creates a list
with elements
ai
's which are arbitrary Scilab objects
(matrix
,
list
,...). Type of
list
objects is 15. list()
creates the empty list
(0 element).
[x,y,z,...]=L(v)
where v
is a vector of indices;
[x,y,z,...]=L(:)
extracts all the elements.
L(i)=a
(note that it is not an
error to use L(i)=a
with
i > 1 + size(L)
but
some list entries are then undefined and their
extraction gives raise to an error).
L($+1)=e
.
L(0)=e
.
![]() | After this
operation e is an index 1,
the initial elements being shifted on the
right. |
L(i)=null()
removes the i
-th element of the list L
.
L3 = lstcat(L1,L2)
.
it is possible to use a list L
with a for loop:
for e=L,...,end
is a loop with length(L)
iterations, the loop variable e
being equal to L(i)
at the i
-th iteration.
Scilab provides also other kinds of list, the tlist type (typed list) and the mlist type which are useful to define a new data type with operator overloading facilities (hypermatrices which are multidimensional arrays in Scilab are in fact mlist).
Matlab struct are also available.
l = list(1,["a" "b"]) // declaration of a basic list with a double & a vector of two strings size(l) // Size is 2 // l(0) - Does not exist! l(1) // Access to the double value l(2) // Access to the vector of strings size(l(2)) // Size is 1,2 l(0) = "foo" // Insert at the beginning of the list // l(0) - still does not exist l(1) // Is "foo" l($+1) = "hello" // Insert at the end l(2) = "toto" // Override my double l(3) = rand(1,2) // Override my vector of string l(3) = null() // Remove the third element lbis = list("gewurtz", "caipirina" ,"debug") // Declare a new list lter = lstcat(l,lbis) // Merge the two list size(lter) - size(lbis) - size(l) // must be zero | ![]() | ![]() |