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
- []
- delete
- xmlDelete
- jremove
- jnull
- jvoid
- list
- mlist
- tlist
- struct