Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
null
deletes a list component or a field of a structure, Mlist, or Tlist
Syntax
List(i) = null() Struct.field = null()
Description
List
being a simple list, List(i)=[]
sets
[]
as the value of the ith component.
Hence, []
can't be used with lists to remove some parts of the
left-hand-side (LHS) object, as it can do it for regular vectors or arrays .
null()
aims to do it. It generates an object of type 0 and
typeof listdelete
that deletes the object to which it is assigned.
The overloading code of listdelete objects is 0. |
Assigning null() to a variable deletes it. However, using
clear should be preferred to clear named objects. |
Examples
type, typeof, and null overloading code:
--> type(null()) ans = 0. --> typeof(null()) ans = listdelete --> null()==null() Undefined operation for the given operands. check or define function %0_o_0 for overloading.
Deletion of a list component:
--> length(L) ans = 4. --> L(2) = null(); --> length(L) ans = 3. --> L(2) ans = F
Deletion of a field of a structure:
s(2,3).r = %pi; s(2,1).p = (1-%z)^2; s(1,2).b = %T s.p = null()
--> s(2,3).r = %pi; --> s(2,1).p = (1-%z)^2; --> s(1,2).b = %T s = 2x3 struct array with fields: r p b --> s.p = null() s = 2x3 struct array with fields: r b
Deletion of a field of a Mlist or Tlist: No default destructor is defined:
ML = mlist(["test" "b" "c" "rp" "t"],[%t %f], %i, 1+%s^2, ["abc" "de" "f"]); fieldnames(ML)' ML.rp ML.rp = null()
--> fieldnames(ML)' ans = !b c rp t ! --> ML.rp ans = 2 1 +s --> ML.rp = null() Function not defined for given argument type(s), check arguments or define function %0_i_test for overloading.
// Let's define a field destructor called by "= null()": function L=%0_i_test(fieldName, Null, L) header = getfield(1,L) i = find(header==fieldName); if i~=[] then header(i) = []; L = setfield(1, header, L); L = setfield(i, null(), L); end endfunction // Let's use it: ML.rp = null(); fieldnames(ML)' ML.b, ML.c, ML.t
--> ML.rp = null(); --> fieldnames(ML)' ans = !b c t ! --> ML.b, ML.c, ML.t ans = T F ans = i ans = !abc de f !
See also
- clear — cancela variáveis
- clearglobal — cancela variáveis globais
- [] — empty matrix. Array ranges destructor.
- delete — Deleta uma entidade gráfica e seus galhos
- xmlDelete — Delete a XML document
- jremove — Remove a Java Object on the Java side
- jnull — The Scilab version of the Java null object.
- jvoid — For no argument functions
- list — objeto do Scilab e definição de lists ("listas")
- mlist — objeto Scilab, definição de listas com tipos orientadas matricialmente
- tlist — objeto do Scilab e definição de listas com tipos ("typed lists")
- struct — Builds a structure or an array of structures
Report an issue | ||
<< mlist | Estruturas de Dados | rlist >> |