Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Data Structures > null

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())
typeof(null())
null()==null()
--> 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:

L = list(1:10, "foo", %f, (1-%z)^2);
length(L)
L(2) = null();
length(L)
L(2)
--> 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 — 変数を消去する
  • clearglobal — グローバル変数を削除
  • [] — empty matrix. Array ranges destructor.
  • delete — グラフィックエンティティとその子を削除.
  • xmlDelete — XML文書を削除
  • jremove — Java側のJavaオブジェクトを削除
  • jnull — Java nullオブジェクトのScilab版.
  • jvoid — 引数なしの関数用
  • list — Scilab オブジェクトおよびリスト関数定義
  • mlist — Scilab オブジェクト, 型付リスト定義に向いた行列.
  • tlist — Scilab オブジェクトおよび型付のリスト定義.
  • struct — 構造体を作成する
Report an issue
<< mlist Data Structures rlist >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:53:23 CET 2020